Macro for last row

F

Freddie Ang

Hi Experts,

Need your help to get this working.
I'm using the below macro to copy formulas up to the last row.
However, it doesn't work when the worksheet have many rows of data (says
50,000 rows). It works fine for fewer rows.

Function last_row() As Integer

Row = 1
While Cells(Row, 1) <> ""
Row = Row + 1
Wend

last_row = Row

End Function


Thanks in advance
 
B

Bob Phillips

Function last_row() As Long
Dim mRow As Long
mRow = 1
While Cells(mRow, 1) <> ""
mRow = mRow + 1
Wend

last_row = mRow

End Function




--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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

Top