VBA - Selecting entire column

satkin2

New Member
Joined
Oct 22, 2009
Messages
25
Hi,
I've got a number of column groups that I want to perform various actions on. I've taken parameters to get these groups as follows...
Code:
Sub Get_Column_Groups()
    'Row titles
    Range("A1").Select
    Col_Group1_From = ActiveCell.Column
    Col_Group1_To = ActiveCell.Column
    Col_Group1_Width = Col_Group1_To - Col_Group1_From + 1
      
    'Months
    Col_Group2_From = ActiveCell.Offset(0, 1).Column
    Col_Group2_To = Selection.End(xlToRight).Offset(0, -9).Column
    Col_Group2_Width = Col_Group2_To - Col_Group2_From + 1
    
    'Blank
    Col_Group3_From = Selection.End(xlToRight).Offset(0, -8).Column
    Col_Group3_To = Selection.End(xlToRight).Offset(0, -8).Column
    Col_Group3_Width = Col_Group3_To - Col_Group3_From + 1
    
    'Monthly Movement
    Col_Group4_From = Selection.End(xlToRight).Offset(0, -7).Column
    Col_Group4_To = Selection.End(xlToRight).Offset(0, -7).Column
    Col_Group4_Width = Col_Group4_To - Col_Group4_From + 1
End Sub

What I now want to do is select the whole columns in say group2.

I can't work out how I select the whole column using these defined column numbers though. Would anyone be able to point me in teh right direction?

Many thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I forgot to mention, the groupings are defined globally...
Code:
Global Col_Group1_From, Col_Group1_To, Col_Group1_Width, _
       Col_Group2_From, Col_Group2_To, Col_Group2_Width, _
       Col_Group3_From, Col_Group3_To, Col_Group3_Width, _
       Col_Group4_From, Col_Group4_To, Col_Group4_Width, _
       Col_Group5_From, Col_Group5_To, Col_Group5_Width, _
       Col_Group6_From, Col_Group6_To, Col_Group6_Width
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top