PDA

View Full Version : UsedRange



XcelV4
09-13-2009, 12:11 PM
Hi all,

I'm trying to get the last row of a spreadsheet so I can append a small table of data below it. I am attempting to use the UsedRange attribute and the Row and Column attributes of that to get the last used row but when I print these values they always appear as "1" irrespective of the amount of data in the worksheet. I must have misinterpreted what the Row and Column refer to in this case. What do they mean and how can I get the last used row of the spreadsheet?

Cheers All

Bob Phillips
09-13-2009, 12:53 PM
Set rng = ActiveSheet.UsedRange
MsgBox rng(rng.Count).Row

p45cal
09-13-2009, 02:07 PM
I must have misinterpreted what the Row and Column refer to in this case. What do they mean and how can I get the last used row of the spreadsheet?

Cheers All
From Help:
Row:"Returns the number of the first row of the first area in the range."
Column:"Returns the number of the first column in the first area in the specified range."

mdmackillop
09-14-2009, 12:18 AM
Note that UsedRange may not always start at A1, which wll affect the value of Row and Column

Bob Phillips
09-14-2009, 12:40 AM
My suggestion caters for that MD, because it counts off of UsedRange.