Reputation: 21
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
Reputation: 21
I resolved this error by activating worksheet as below:
Dim sht As Worksheet
Set sht = ActiveWorkbook.ActiveSheet
Upvotes: 1