Dim valCheck As Variant
For i = 0 To row1
For j = 0 To col1
MsgBox ("started" & i)
valCheck = Range("A1").Offset(i, j).Value
MsgBox (valCheck)
If valCheck = "Details" Then
MsgBox ("found")
ActiveCell = Range("A1").Offset(i + 1, j)
Exit For
Exit For
End If
Next j
Next i
最佳答案
你不需要有 2 For
循环和 Exit For
,您可以简单地使用 Find
代替功能。
Dim FindRng As Range
Set FindRng = Cells.Find("Details")
If Not FindRng Is Nothing Then ' Find was successful
FindRng.Select ' <-- not sure what you want to do after you find the cell with "Details" ?
Else ' Find failed
MsgBox "Unable to find 'details'", vbCritical
End If
关于vba - Excel VBA Exit For 在 If block 内不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49584731/