0
我是新来编写VBA代码,并且在线下面遇到了这个代码,这与我正在尝试做的非常相似。但是,当我尝试运行它时,它会突出显示Loop While Not c Is Nothing And c.Address <> firstAddress
行,并弹出一条消息,提示“对象变量或块变量未设置”。Excel VBA代码
有谁知道如何解决这个问题?任何帮助深表感谢!
Sub Commodity()
'
' Commodity Macro
' Commodity
'
'
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
太棒了!感谢您的快速,有益的回应:) –