BVS
BVS

Reputation: 21

VBA Run time error 424: Object required

I have a simple code to find first and last row populated in excel. When I execute this I get error VBA Run time error 424: Object required. I searched other 424: object required errors but it doesn't give specifics on this particular logic. I tried Lf both as integer and string.

Sub lastrow()
Dim Lf As Integer
Lf = sht.Cells(sht.Rows.Count, Range("Lastrow").Column).End(xlUp).Row
End Sub

Can anyone please help with this?

Upvotes: 1

Views: 7485

Answers (1)

BVS
BVS

Reputation: 21

I resolved this error by activating worksheet as below:

Dim sht As Worksheet
Set sht = ActiveWorkbook.ActiveSheet

Upvotes: 1

Related Questions