Автор: kansky
Дата сообщения: 05.03.2007 10:33
Добрый день!
Помогите плз найти причину ошибки 91 (Object variable or With block variable not set ).
Причем если убираю вызовы (их 2) другого макроса (Application.Run "'Оплата безналом2003.xls'!NewZaivkaVuvod"), то ошибки нет. По отдельности макросы работают.
Код
Sub VuvodZaivki1()
'excecute the first find
Dim c As Range
Dim curZaivka(30) As Long
Dim iZaivka As Integer
Dim firstAddress As String, lastaddress As String
iZaivka = 0
Worksheets("Заявки").Activate
Range("A1").Activate
'поиск 1
Set c = ActiveSheet.Cells.Find(What:="@", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If Not c Is Nothing Then
'1
firstAddress = c.Address
'2
lastaddress = c.Address
'3
curZaivka(iZaivka) = Worksheets("Заявки").Range("A" & c.Row)
MsgBox (curZaivka(iZaivka))
'4
iZaivka = iZaivka + 1
Range("C" & c.Row).Activate
'5 reserved
Worksheets("Вывод").Range("A1").Formula = "=Заявки!A" & c.Row
'6 reserved
Application.Run "'Оплата безналом2003.xls'!NewZaivkaVuvod"
'следующий поиск
Do While c.Address <> firstAddress & iZaivka <> 1
' Range("C" & c.Row).Activate
Set c = ActiveSheet.Cells.Find(What:="@", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
'2
??? lastaddress = c.Address ///ВОТ ТУТ ДАЕТ ОШИБКУ
If c.Address = firstAddress Then
Exit Do
firstAddress = ""
lastaddress = ""
iZaivka = 0
End If
'3
curZaivka(iZaivka) = Worksheets("Заявки").Range("A" & c.Row)
MsgBox (curZaivka(iZaivka))
'4
iZaivka = iZaivka + 1
'5 reserved
Worksheets("Вывод").Range("A1").Formula = "=Заявки!A" & c.Row
'6 reserved
'Application.Run "'Оплата безналом2003.xls'!NewZaivkaVuvod"
'следующие поиски продолжение
Range("C" & c.Row).Activate
Loop
Else
firstAddress = ""
lastaddress = ""
iZaivka = 0
MsgBox ("Не найдено")
End If
Set c = Nothing
End Sub