Range.FindNext Method

Классический пример из справки

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

Столкнулся с ситуацией, когда этот участок начал выдавать ошибку:

Run-time error ’91’:

Object variable or With block variable not set

c.Address стало Nothing !

Потом разберусь, а пока

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)
            If c Is Nothing Then Exit Do
        Loop While c.Address <> firstAddress
    End If
End Sub

 

Оставить комментарий

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.