Find the last used Row on a Worksheet

  • Thread starter Thread starter poppy
  • Start date Start date
P

poppy

Hi Experts

Is it possible for me to select the blank row immediately after th
last used row? I am trying to do something like this, but it's no
working:


Code
-------------------
lastrow = Cells(Rows.count, "B").End(xlUp).Row
lastrow2 = lastrow + 2
Range("A65536").End(xlToRight).Select = "lastrow2"

OR

Range("lastrow2").End(xlToRight).Select
 
The UsedRange property of the worksheet will get it for you:
LastRow = Worksheets(SheetName).UsedRange.Rows.Count
(this gives the last used row, the blank row would be this plus one)
 
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Range("B" & lastrow+1).Value = "lastrow2"

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Hi K Dales

This is only working if you have data in the first row of your sheet

You can use this to find the last row with data

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1
 

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