Help with Run-time error '1004':

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
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

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.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Change Range to Cells on that line.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top