Find last row with data


Gene Augustin

MAC Powerbook G4, OS 10.5.6, Excel 2004

I have a worksheet with a column with first cell value in column DATE,, then
a bunch of rows in that column with either a date or an empty cell. I'm
trying to find the last cell with a date in that column.

I've tried all of the following, none works. Using the immediate window,
Lastcell is always 1 and xlUP is -4162 after execution. Can you suggest a
proper code?

Sub LastRowWithDate()

'Find Last row with date
'LastRow = Cells(65536, 1).End(xlUp).Row
'LastRow = Cells(65536,1).End(xlUp).Row
'LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
LastRow = Cells(Cells.Rows.Count).End(xlUp).Row

End Sub



In this way you can determine the last row in ONE column, e.g. in column C:
LastRow = Range("C" & Rows.Count).End(xlUp).Row


„Gene Augustin†ezt írta:

Dave Peterson

I'd use:

dim LastRow as long
with worksheets("Somesheetnamehere")
'assuming the dates are in column K
lastrow = .cells(.rows.count,"K").end(xlup).row
end with

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