Hello all,
I'm trying to run code that searches for an entry on one sheet from another. I did a function and here is the code
Now i'm getting a Run-time error '1004' on the lrow = line.
When i put my cursor over the NOCws.Range portion in debug it gives me the following:
NOCws.Range(Row.Count, 3)....=Method 'Range of object'_Worksheet' Failed
Now this code was working fine before but now it is causing issues and i need it to work or a major component of my job will be made harder. Please help if possible.
I'm trying to run code that searches for an entry on one sheet from another. I did a function and here is the code
VBA Code:
Function FDAGRNOC(rw As Long)
Dim STws As Worksheet, NOCws As Worksheet
Set STws = ThisWorkbook.Worksheets("Permits")
Set NOCws = ThisWorkbook.Worksheets("NOC")
lrow = NOCws.Range(Rows.Count, 3).End(xlUp).Row
With NOCws.Range("D4:D" & lrow)
AGR = STws.Cells(rw, "H").Value
Set NOCr = .Find(AGR, LookIn:=xlValues)
If Not NOCr Is Nothing Then
FDAGRNOC = NOCr.Row
End If
End With
End Function
Now i'm getting a Run-time error '1004' on the lrow = line.
When i put my cursor over the NOCws.Range portion in debug it gives me the following:
NOCws.Range(Row.Count, 3)....=Method 'Range of object'_Worksheet' Failed
Now this code was working fine before but now it is causing issues and i need it to work or a major component of my job will be made harder. Please help if possible.