Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find last Row with value

3 views
Skip to first unread message

Gene Augustin

unread,
Feb 26, 2009, 8:47:51 PM2/26/09
to
I originally posted this in the windows Excel microsoft.public.excel.misc
The help I received probably works in a WIN environment, but not MAC.

*****
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

Shane Devenshire

unread,
Mar 6, 2009, 2:28:01 AM3/6/09
to
Hi,

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

0 new messages