可能重复:
excel 宏:ByRef 参数类型不匹配
我写了如下代码:
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
....
我想将它们总结成一个新的 sub(...) 来调用,但是在我测试后它有错误。
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
如何修改它?我真的需要一些建议。thx