*****
MAC Powerbook G4, OS 10.5.6, Excel 2004
I have a worksheet with a column with first cell value in that column DATE,
then a bunch of rows in that column with either any value or an empty cell.
I'm trying to find the last cell with any value in that column.
I've tried all of the following, none works ( except the trivial LastRow =
32 . Using the immediate window, Lastcell is always 1 and xlUP is -4162
after execution. Can you suggest a proper code?
Sub RemoveEmpty_AddItemNumber()
'Find Column to use This works
Cells.Find(What:="Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
firstrow = ActiveCell.Row 'This works
'Find Last row with data
'Assume date in col c, I usually don't know this in advance
'None of the following work
'LastRow = Range("c" & Rows.Count).End(xlUp).Row
'LastRow = Cells(65535, 1).End(xlUp).Row
'LastRow = Cells(65536,1).End(xlUp).Row
'LastRow = .Cells(.Rows.Count, "c").End(xlUp).Row
' LastRow = Cells(Cells.Rows.Count).End(xlUp).Row
'LastRow = Cells(.Rows.Count, "c").End(xlUp).Row
'LastRow = 32
'LastRow = Cells(65536, 1).Row
End Sub
Gene
If you are trying this in column A for example the code would be
Range("A65536").End(XLUp).Select
or
myRow = Range("A65536").End(XLUp).Row
or
myValue = Range("A65536").End(XLUp).Value
--
If this helps, please click the Yes button.
Cheers,
Shane Devenshire