Last Row of Selection

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hello,
Is there a different way of getting the last row of a selection? The first
row is selection.rows(1).row, but I can't get the last row without counting
rows and subtracting one.

lastrow = selection.rows(1).row+selection.rows.count-1

Thanks.

Bill
 
What is wrong with that way? You do't need rows(1), just

lastrow = selection.row+selection.rows.count-1

An alternative is

LastRow = rng(rng.Count).Row
 
LastRow = Selection.Rows(Selection.Rows.Count).Row

Not much prettier and much more difficult to read.

Mike F
 
Maybe easier to read:

with selection
LastRow = .Rows(.Rows.Count).Row
end with

and I like:

with selection
LastRow = .cells(.cells.Count).Row
end with

(just to be different!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top