Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't believe you will have much luck with that. Here is an excerpt from
the VBA help file: When applied to a Range object that's a multiple-area selection, this property returns columns from only the first area of the range. For example, if the Range object has two areas- A1:B2 and C3:D4- Selection.Columns.Count returns 2, not 4. To use this property on a range that may contain a multiple-area selection, test Areas.Count to determine whether the range contains more than one area. If it does, loop over each area in the range. You would have to use Columns.Count for the selected range, then add that result -1 to the starting column number to get the column range. i.e. If you select D4:J4, then Selection.Column.Count would yield a count of 7. You know you are in coluimn D or Columns(4), so if you add 7 - 1 or 6, it gives you 10, therefor, your range is columns 4:10. "Dan Thompson" wrote in message ... I am having trouble with this macro Sub ReturnColumnNumbers() Dim ColNum As Integer ColNum = Selection.Column MsgBox ("The Selected Column Numbers are" & Chr(13) & ColNum) End Sub The problem is it works when I select just one column but if I select more than one column it does not return the other column numbers ? Any thoughts ? Dan Thompson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need help with Procedure to return selected column numbers | Excel Programming | |||
how to sort a column of Randomly selected numbers? | Excel Worksheet Functions | |||
Function to return # of column with min value in selected rows | Excel Worksheet Functions | |||
Increment numbers in column A by 1 when selected | Excel Programming | |||
Add selected numbers in a column that are a different color | Excel Discussion (Misc queries) |