【发布时间】:2018-06-10 17:08:11
【问题描述】:
很久以后我又回到了 VBA,并试图实现一个循环来查找多次出现的值。我挣扎了一下,用拖网拖网。我找到了这个例子;
Sub Button1_Click()
With Worksheets(1).Range("a1:a50")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 99
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
这来自 MSDN (https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-find-method-excel),所以我倾向于认为这是一个很好的例子。我重新设计了这个以适合我的应用程序,但出现了错误。然后我尝试直接运行 MSDN 给出的示例。我得到了同样的错误,如下所示。出现这种情况就行了
Loop While Not c Is Nothing And c.Address <> firstAddress
任何人都可以对此有所了解。我真的很惊讶 MSDN 示例不起作用。
感谢期待
【问题讨论】: