Select column using a combo box??

limeister

New Member
Joined
Feb 2, 2010
Messages
19
Hello Excel gurus,

I am a bit weary of asking for help because it's only my 2nd post and I haven't helped out anyone here. Sorry guys. I am not a excel expert.

I have created a userform with a combobox. The combo box is already linked with dates. i.e. When I click on combo box I can select a date.

This was the easy part.

My question is it possible to select a column or a specified range based on what I select in my combobox?

For example, If I select the date 06-Jan-2010 from the combo box, I want to be able to make Column A active.

If I chose 13-Jan-2010 then Column B is active.

Basically want and try and do this for the entire 2010 year so I guess I need 52 separate lines of code?!?

Thanks in advance.

p.s. I made this userform from basically cut and pasting and modifying codes I found on the internet. Don't understand a thing about VB. Sorry.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You have to do like this:

Code:
Private Sub ComboBox1_Change()
    
    If ComboBox1.Value = "06-Jan-2010" Then
        Columns("A:A").Select
    End If
    
End Sub
 
Upvote 0
Thanks for that! I was dreading it might require 52 lines of code!!
No worries. I guess there is no other way.
 
Upvote 0
Assuming that 6.Jan'10 is the first entry in the combo box's list, etc.
Code:
Private Sub ComboBox1_Change()
    With ComboBox1
        If -1 < .ListIndex Then
            ThisWorkbook.Sheets("Sheet1").Columns(.ListIndex + 1).Select
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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