aab
aab

Reputation: 1739

Excel VBA to find the last row on a sheet

I'm trying to paste data into a worksheet below the data. I've got the following:

Set BaseWks = Workbooks("Data.xlsx").Worksheets("Total Data")
    rnum = BaseWks.Worksheets("Total Data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)

But it gives me an error: method or data member not found. What am I doing worng?

Upvotes: 0

Views: 59

Answers (1)

SJR
SJR

Reputation: 23081

You just need

rnum = BaseWks.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).row

as you have already defined BaseWks as that sheet.

You also need .row on the end to return the row number.

If you want the cell itself you need Set rnum= ... instead.

Upvotes: 2

Related Questions