Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect selected column Fareez Excel Discussion (Misc queries) 1 February 20th 09 06:50 AM
HOW DO I ALPHABETIZ A SELECTED COLUMN Ann Longley Excel Worksheet Functions 1 May 22nd 06 05:16 PM
Don't run if entire column is selected Elaine Excel Programming 4 March 21st 05 02:01 AM
Is column selected Josh Sale Excel Programming 3 August 10th 04 02:47 PM
how to know the column/row of a selected cell in vba? daryl Excel Programming 4 May 5th 04 03:59 PM


All times are GMT +1. The time now is 08:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"