![]() |
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? |
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? |
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? |
All times are GMT +1. The time now is 10:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com