Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Capturing the column number and # of columns in a selection

What is the best way to capture the number of the 1st column and the number
of columns of an area selected by a user?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Capturing the column number and # of columns in a selection

To get the first column of the selection, use

Dim ColNum As Integer
ColNum = Selection.Cells(1,1).Column

To get the number of columns selected, use

Dim ColCount As Integer
ColCount = Selection.Columns.Count


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ralph Heidecke" wrote in message
...
What is the best way to capture the number of the 1st column
and the number
of columns of an area selected by a user?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Capturing the column number and # of columns in a selection

Just some supplemental information:

You can also simply use selection.column for the first column.

and to state explicitly what Chip stated implicitly when he said
Dim ColNum as Integer
these methods return the column number, not the column letter - but I have
never seen a case where I needed the column letter to do anything.

--
Regards,
Tom Ogilvy

"Chip Pearson" wrote in message
...
To get the first column of the selection, use

Dim ColNum As Integer
ColNum = Selection.Cells(1,1).Column

To get the number of columns selected, use

Dim ColCount As Integer
ColCount = Selection.Columns.Count


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ralph Heidecke" wrote in message
...
What is the best way to capture the number of the 1st column
and the number
of columns of an area selected by a user?






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
Changing the number of columns within existing column(s) tkdmom Excel Discussion (Misc queries) 1 November 18th 09 09:33 PM
How do I turn excel columns from column number to column letter? column Setting up and Configuration of Excel 1 April 29th 08 10:15 AM
Multiply two columns in Excel or one column by one number Axia's Mom New Users to Excel 1 January 12th 06 03:22 AM
Need to indirectly reference columns 26 using A1 notation based on numeric column number- how to? KR Excel Worksheet Functions 5 October 26th 05 07:08 PM
Data from a number of rows and columns to one column mark_h82 Excel Discussion (Misc queries) 2 January 15th 05 03:02 AM


All times are GMT +1. The time now is 10:01 PM.

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

About Us

"It's about Microsoft Excel"