我写了如下代码:
Call search(xx, yy, "APM Output", ">> State Scalars", label1)
label1:
...........
这是子搜索的脚本
Sub search(row As Variant, col As Variant, wkst As String, str As String, label_num As Name)
For row = 1 To 100
For col = 1 To 100
strTemp = Worksheets(wkst).Cells(row, col).Value
If InStr(strTemp, str) <> 0 Then
GoTo label_num
End If
Next
Next
End Sub
我想先调用 sub search(..),然后转到 label1。问题是说 label_num 的“ByRef 参数类型不匹配”。Sub search(..,..,.., label_num ) 中 label_num 的正确类型应该是什么?
我添加了一些原始脚本,这些是我想要转换成 sub()
For xx = 1 To 100
For yy = 1 To 100
strTemp = Worksheets("APM Output").Cells(xx, yy).Value
If InStr(strTemp, ">> State Scalars") <> 0 Then
GoTo label1
End If
Next
Next
label1:
For uu = 1 To 100
For vv = 1 To 100
strTemp = Worksheets("APM Output").Cells(uu, vv).Value
If InStr(strTemp, ">> GPU LPML") <> 0 Then
GoTo label2
End If
Next
Next
label2:
For mm = 1 To 100
For nn = 1 To 100
strTemp = Worksheets("APM Output").Cells(mm, nn).Value
If InStr(strTemp, ">> Limits and Equations") <> 0 Then
GoTo label3
End If
Next
Next