View Full Version : Solved: Finding Last column in Row
jazzyt2u
04-16-2009, 01:29 PM
Hi,
I know how to find the last row in a column:
MyLoc = ActiveCell.AddressLocal(RowAbsolute:=False, ColumnAbsolute:=False)
MyLoc = Left(MyLoc, Len(MyLoc) - 2)
Range(MyLoc & Rows.Count).End(xlUp).Select
Now I just need to know how to find the last column in a row where there are blank cells in the row preventing me from doing:
Selection.end(xltoRight).select
Please help!!!! :-)
p45cal
04-16-2009, 01:40 PM
lastcolumn = Cells(Selection.Row, Columns.Count).End(xlToLeft).Column
MsgBox lastcolumnor
Cells(Selection.Row, Columns.Count).End(xlToLeft).Select
jazzyt2u
04-16-2009, 02:26 PM
Thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Can I use "selection.column" when trying to find the last row of a column????
As you can see from above in my first entry I put in a couple of lines of code to just get the column...
p45cal
04-16-2009, 02:41 PM
Yes:
cells(rows.count,selection.column).end(xlUp).select but you'd have got a quicker answer if you'd tried it!
mdmackillop
04-16-2009, 02:52 PM
These solutions assume a single cell selection which may be misleading
If your Selection was A1:A10 and A5 was the longest row, you will return the rightmost cell in Row 1.
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Select
would return a valid answer for the active cell.
jazzyt2u
04-16-2009, 03:19 PM
I did try it but what I was doing didn't work. I see that i had to switch a few things around... So thanks again...
jazzyt2u
04-16-2009, 03:20 PM
Now I see what I did wrong... duh... I do have a headache today... :-)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.