我无法找到
的原因无效的过程调用或参数(错误5)
发生在我正在操作的表的最后一行。
我尝试过相同格式的不同表,并发现它们工作得很好。这让我相信表格中的特定行存在问题
相关代码:
VName.Value = RID.Value & " " & IIf(InStr(1, RID.Offset(columnOffset:=1).Value, vbCrLf) <> 0 And _
(InStr(1, RID.Offset(columnOffset:=1).Value, vbCrLf) - 1) >= 10, _
Left(RID.Offset(columnOffset:=1).Value, InStr(1, RID.Offset(columnOffset:=1).Value, vbCrLf) - 1), RID.Offset(columnOffset:=1).Value)
完整代码:
'~~~> For Each Row
'~~~> ID Row (offset by 2 columns) with SectionTitle (Cache A3) + ID starting with 0 on the header
Set RID = Nothing
Set SecT = Range("'Values'!$A$3")
Set RCount = .Range(.Cells(HC, 2), .Cells(.Cells(Rows.count, 2).End(xlUp).Row, 2))
IDCount = 0
For Each RID In RCount
'ID Req rows
RID.Offset(columnOffset:=-1).Value = SecT.Value & " " & IDCount
'~~~> Add ID, ReqName, Section to Values sheet where if ID is 0 then Type = Folder
Set VSection = Worksheets("Values").Cells(Worksheets("Values").Cells(Rows.count, 2).End(xlUp).Row + 1, 2)
VSection.EntireRow.ClearContents
Set VName = Worksheets("Values").Cells(Worksheets("Values").Cells(Rows.count, 2).End(xlUp).Row + 1, 3)
Set VType = Worksheets("Values").Cells(Worksheets("Values").Cells(Rows.count, 2).End(xlUp).Row + 1, 4)
Set VID = Worksheets("Values").Cells(Worksheets("Values").Cells(Rows.count, 2).End(xlUp).Row + 1, 5)
'Row = Header where IDCount = 0
If IDCount = 0 Then
VSection.Value = SecT.Value
VName.Value = SecT.Value
VType.Value = "Folder"
VID.Value = IDCount
'Row <> Header where IDCount > 0
ElseIf IDCount > 0 Then
VSection.Value = SecT.Value
VName.Value = RID.Value & " " & IIf(InStr(1, RID.Offset(columnOffset:=1).Value, vbCrLf) <> 0 And _
(InStr(1, RID.Offset(columnOffset:=1).Value, vbCrLf) - 1) >= 10, _
Left(RID.Offset(columnOffset:=1).Value, InStr(1, RID.Offset(columnOffset:=1).Value, vbCrLf) - 1), RID.Offset(columnOffset:=1).Value)
VName.WrapText = False
VID.Value = IDCount
End If
IDCount = IDCount + 1
Next RID
RID.Value = FLO.1170
RID.Offset(columnOffset:=1).Value = WORKITEM MANAGEMENT
触发
无效的过程调用或参数(错误5)
由于“WORKITEM MANAGEMENT”中没有换行符,它应该使用完整的单元格值而不是Left函数。其他113排工作正常。
答案 0 :(得分:0)
Left(<string>, <length>)
与数字 10 进行比较。这可能不正确。如果从Left method返回看起来像数字的文本,则将其包装在CLng()或CDbl()中以获得实际数字。也许.Split function会是更好的选择。如果Split找不到实际拆分的分隔符,您仍然会将原始值作为从零开始的元素。
VName.Value = RID.Value & " " & Split(RID.Offset(columnOffset:=1).Value, Chr(10))(0)