I can find the Last Row -- How about the last column??


Posted by bill.roberts on March 03, 2000 1:26 PM

Finding the last looks like this:

....FinalRow = Range("A65536").End(xlUp).Row

Finding the last column SHOULD like like this:

....FinalColumn = Range("IV1").End(xlLeft).Column

But it's not the answer...

Posted by Celia on March 03, 2000 4:15 PM

Bill

Should be :- End(xlToLeft)

You could have got this by using the macro recorder.

Celia

PS. Does your code work exactly as you've typed it (with "row" and "column" at the end)? This doesn't look right to me.

Posted by Jeff Mathewson on March 06, 2000 7:39 AM

Try this:


FinalRow = Range("A65536").End(xlUp).Row
do While cells(FinalRow,1) = ""
FinalRow = FinalRow - 1
Loop
FinalColumn = Range("IV1").End(xlToLeft).Column
Do While Cells(1,FinalColumn) <> ""
FinalColumn = FinalColum - 1
Loop
End Sub

Jeff.



Posted by Jeff Mathewson on March 10, 2000 6:12 AM

Celia,

Yes your right and I found that I did make an error when I posted the message. I forgot to add Trim to the statement. In the past, I found that "FinalRow = Range("A65536").End(xlUp).Row" always didn't work due to cells that looked emty but were not due to unseen spaces in the cell.

FinalRow = Range("A65536").End(xlUp).Row
do While trim(cells(FinalRow,1)) = ""
FinalRow = FinalRow - 1
Loop
FinalColumn = Range("IV1").End(xlToLeft).Column
Do While trim(Cells(1,FinalColumn)) <> ""
FinalColumn = FinalColum - 1
Loop
End Sub

Jeff.