Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Hi all, I know how to get the last row with the column "hard coded" IE: Code: -------------------- Sub Example1() Cells(Cells.Rows.Count, "A").End(xlUp).Select End Sub -------------------- But instead of hard coding a column i want to select the column. something like: Code: -------------------- Sub Example2() Cells(Cells.Rows.Count, "With Selection").End(xlUp).Select End Sub -------------------- It dosen't work of course. Any direction on this would be appreciated. Thx Dave -- Desert Piranha ------------------------------------------------------------------------ Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934 View this thread: http://www.excelforum.com/showthread...hreadid=487496 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Hello Desert Piranha, Dim Col Cells(Cells.Rows.Count, Col).End(xlUp).Select Since Col is a variant it can then be a string like "A" or a number like 1. RETURN THE FIRST COLUMN OF A SELECTION: FirstCol = Selection.Column RETURN THE LAST COLUMN OF A SELECTION: With Selection LastCol = .Columns.Count + .Column - 1 End With Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=487496 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Try:
Sub Example1() Cells(Rows.Count, ActiveCell.Column).End(xlUp).Select End Sub Regards Rowan Desert Piranha wrote: Hi all, I know how to get the last row with the column "hard coded" IE: Code: -------------------- Sub Example1() Cells(Cells.Rows.Count, "A").End(xlUp).Select End Sub -------------------- But instead of hard coding a column i want to select the column. something like: Code: -------------------- Sub Example2() Cells(Cells.Rows.Count, "With Selection").End(xlUp).Select End Sub -------------------- It dosen't work of course. Any direction on this would be appreciated. Thx Dave |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Hi Dave,
Try: '=========== Public Sub Example2() Cells(Cells.Rows.Count, _ ActiveCell.Column).End(xlUp).Select End Sub '<<=========== PS: Desert?! --- Regards, Norman "Desert Piranha" <Desert.Piranha.1yxlhz_1132718402.6354@excelforu m-nospam.com wrote in message news:Desert.Piranha.1yxlhz_1132718402.6354@excelfo rum-nospam.com... Hi all, I know how to get the last row with the column "hard coded" IE: Code: -------------------- Sub Example1() Cells(Cells.Rows.Count, "A").End(xlUp).Select End Sub -------------------- But instead of hard coding a column i want to select the column. something like: Code: -------------------- Sub Example2() Cells(Cells.Rows.Count, "With Selection").End(xlUp).Select End Sub -------------------- It dosen't work of course. Any direction on this would be appreciated. Thx Dave -- Desert Piranha ------------------------------------------------------------------------ Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934 View this thread: http://www.excelforum.com/showthread...hreadid=487496 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Hi all, Leith, Rowan, Norman, Thx for your fast and wonderfull input. It's all great, and solved my issue. Norman - Yes "Desert" I'm in the desert of Arizona, USA, - Scorpions, Rattle Snakes, Black Widows, Coyotes, Tarantulas, and Catcus. My nickname is Piranha, hence Desert Piranha. Norman Jones Wrote: Hi Dave, Try: '=========== Public Sub Example2() Cells(Cells.Rows.Count, _ ActiveCell.Column).End(xlUp).Select End Sub '<<=========== PS: Desert?! --- Regards, Norman "Desert Piranha" <Desert.Piranha.1yxlhz_1132718402.6354@excelforu m-nospam.com wrote in message news:Desert.Piranha.1yxlhz_1132718402.6354@excelfo rum-nospam.com... Hi all, I know how to get the last row with the column "hard coded" IE: Code: -------------------- Sub Example1() Cells(Cells.Rows.Count, "A").End(xlUp).Select End Sub -------------------- But instead of hard coding a column i want to select the column. something like: Code: -------------------- Sub Example2() Cells(Cells.Rows.Count, "With Selection").End(xlUp).Select End Sub -------------------- It dosen't work of course. Any direction on this would be appreciated. Thx Dave -- Desert Piranha ------------------------------------------------------------------------ Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934 View this thread: http://www.excelforum.com/showthread...hreadid=487496 -- Desert Piranha ------------------------------------------------------------------------ Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934 View this thread: http://www.excelforum.com/showthread...hreadid=487496 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Hi Dave,
Norman - Yes "Desert" I'm in the desert of Arizona, USA, - Scorpions, Rattle Snakes, Black Widows, Coyotes, Tarantulas, and Catcus. My nickname is Piranha, hence Desert Piranha. Thank you for the information. The Desert portion appeared to be a new appellation - hence the query. --- Regards, Norman |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last row - Selected Column
Hi Norman, Yes, just evolving along with the critters. :) DaveNorman Jones Wrote: Hi Dave, Norman - Yes "Desert" I'm in the desert of Arizona, USA, - Scorpions, Rattle Snakes, Black Widows, Coyotes, Tarantulas, and Catcus. My nickname is Piranha, hence Desert Piranha. Thank you for the information. The Desert portion appeared to be a new appellation - hence the query. --- Regards, Norman -- Desert Piranha ------------------------------------------------------------------------ Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934 View this thread: http://www.excelforum.com/showthread...hreadid=487496 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Protect selected column | Excel Discussion (Misc queries) | |||
HOW DO I ALPHABETIZ A SELECTED COLUMN | Excel Worksheet Functions | |||
Don't run if entire column is selected | Excel Programming | |||
Is column selected | Excel Programming | |||
how to know the column/row of a selected cell in vba? | Excel Programming |