Hi,
I have a query regarding my code. I am not sure why am I getting this error when I am calling another macro.
I found out that when I am at the MasterData sheet macro works fine. I suspect it there is some discrepancy with the find function and I like to know why.
The highlighted debug line is: i = foundeqp.Row
Appreciate your help.
Any good books to recommend? I read 2 but there is not much info about troubleshooting
-Krey
I have a query regarding my code. I am not sure why am I getting this error when I am calling another macro.
I found out that when I am at the MasterData sheet macro works fine. I suspect it there is some discrepancy with the find function and I like to know why.
The highlighted debug line is: i = foundeqp.Row
Appreciate your help.
Any good books to recommend? I read 2 but there is not much info about troubleshooting
Code:
Private Sub NZZ()
Sheets("EqpData").Cells(2, 3).Value = "NZ90"
Application.Run "Findeqp"
End Sub
-----------------------------------------------------------------------------------------------------
Sub Findeqp()
Dim searchrange As Range
Dim foundeqp As Range
Dim lastrowmasterdata As Range
Dim lastroweqpdata As Integer
Dim aftercell As Range
Dim eqpname As String
Dim i As Integer
Dim n As Integer
eqpname = Sheets("EqpData").Cells(2, 3).Value
Set searchrange = ThisWorkbook.Worksheets("MasterData").Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)
n = 0
i = 1
Do
Set aftercell = Sheets("MasterData").Cells(i, 2)
lastroweqpdata = Sheets("EqpData").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Set foundeqp = searchrange.Find(what:=eqpname, After:=aftercell, MatchCase:=False, LookAt:=xlWhole)
i = foundeqp.Row
MsgBox "i is " & i
If i >= n Then
foundeqp.EntireRow.Copy Destination:=Sheets("EqpData").Cells(lastroweqpdata, 1)
n = i
Else
Exit Do
End If
Loop While i >= n
End Sub
-Krey