Reputation: 97
Dim LastRow As Long
With Workbooks("SampleBook").Sheets("SampleSheet")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
I have been running this code for over a month now. I had no issues. Suddenly, for the past two days, it's throwing the subscript out of range - run time error(9).
Not sure what's going on!
Your help is appreciated :)
Thank you!
Upvotes: 0
Views: 75
Reputation: 97
Figured it out!! I had enabled the show file extension option in folder options. I needed to add the extension to my workbook name. The following modification worked
With Workbooks("SampleBook.xlsm").Sheets("SampleSheet") LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row End With
Upvotes: 1