VB code for Combo Box

kino4city

New Member
Joined
May 17, 2011
Messages
11
Hi all,
As i have previously said, I'm not very good with VB.
I have created a couple of forms with combo box's also with frames on there.

First of all I am trying to get the combo lists to ignore blanks in my selection.
eg. "worksheet.data($A$2:$A$10)
Also I am after the selection to change the chart shown.

All my charts have a different sheets in excel.

eg.

If my combobox = "GK DEFEND" then i want it to show "worksheet.GK DEFEND"
in "Frame1" or if it = "worksheet.SWEEPER Keeper" then show "worksheet.SW GK"
if non of the above then show "worksheet.GK"

If anyone can help that would be much apprieciated.

Just an example would be great then i can amend and learn how to do it myself.

Many Thanks,
Chris
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Code:
Private Sub UserForm_Initialize()
    Dim cell As Range
    With ComboBox1
        .RowSource = ""
        For Each cell In Sheets("Data").Range("A2:A10")
            If cell.Value <> "" Then .AddItem cell.Value
        Next cell
    End With
    
    Frame1.Caption = "worksheet.GK"
End Sub

Private Sub ComboBox1_Change()
    Select Case ComboBox1.Value
        Case "GK DEFEND": Frame1.Caption = "GK DEFEND"
        Case "SWEEPER Keeper": Frame1.Caption = "worksheet.SW GK"
        Case Else: Frame1.Caption = "worksheet.GK"
    End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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