Combox box to control Tab control pages

coucar3456

New Member
Joined
Jun 29, 2016
Messages
11
All,

Is it possible for my combo box which has multiple named values starting with Equip-A, Equip-B, Equip-C..etc to navigate directly to my tab control page 1, 2, and 3..etc. The combo box is on the same form as the tab control pages.

Combo box value Equip-A would navigate directly to Tab Control page 1
Combo box value Equip-B would navigate directly to Tab Control page 2
Combo box value Equip-C would navigate directly to Tab Control page 3

Thanks
Coucar
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Place the following code in the userform code module...

Code:
[COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]

[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Sub[/COLOR] ComboBox1_Change()
    [COLOR=darkblue]Dim[/COLOR] sEquip [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
    [COLOR=darkblue]Dim[/COLOR] iIndex [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Integer[/COLOR]
    [COLOR=darkblue]With[/COLOR] Me.ComboBox1
        sEquip = .Value
        [COLOR=darkblue]If[/COLOR] Len(sEquip) > 0 [COLOR=darkblue]Then[/COLOR]
            [COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] IsError(Application.Match(sEquip, .List, 0)) [COLOR=darkblue]Then[/COLOR]
                [COLOR=darkblue]Select[/COLOR] [COLOR=darkblue]Case[/COLOR] sEquip
                    [COLOR=darkblue]Case[/COLOR] "Equip-A"
                        iIndex = 0 [COLOR=#008000]'page 1[/COLOR]
                    [COLOR=darkblue]Case[/COLOR] "Equip-B"
                        iIndex = 1 [COLOR=#008000]'page 2[/COLOR]
                    [COLOR=darkblue]Case[/COLOR] "Equip-C"
                        iIndex = 2 [COLOR=#008000]'page 3[/COLOR]
                [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Select[/COLOR]
                Me.TabStrip1.SetFocus
                Me.TabStrip1.Value = iIndex
            [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

Actually, if the list in your combobox and tabstrip control are in the same corresponding order, the following would suffice...

Code:
[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Sub[/COLOR] ComboBox1_Change()
    [COLOR=darkblue]Dim[/COLOR] sEquip [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
    [COLOR=darkblue]With[/COLOR] Me.ComboBox1
        sEquip = .Value
        [COLOR=darkblue]If[/COLOR] Len(sEquip) > 0 [COLOR=darkblue]Then[/COLOR]
            [COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] IsError(Application.Match(sEquip, .List, 0)) [COLOR=darkblue]Then[/COLOR]
                Me.TabStrip1.SetFocus
                Me.TabStrip1.Value = .ListIndex
            [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

Change the name of the combobox and tabstrip, accordingly. And, of course, if you meant that you had a multipage control and not a tabstrip control, replace TabStrip1 with MultiPage1 (or whatever you've name it).

Hope this helps!
 
Upvote 0
I think we would need to make a couple of changes. First, the MatchEntry property of the combobox should be set to...
Code:
2-fmMatchEntryNone

Secondly, Select Case should be case-insensitive...

Code:
Private Sub ComboBox1_Change()
    Dim sEquip As String
    Dim iIndex As Integer
    With Me.ComboBox1
        sEquip = .Value
        If Len(sEquip) > 0 Then
            If Not IsError(Application.Match(sEquip, .List, 0)) Then
                [COLOR=#ff0000]Select Case UCase(sEquip)
                    Case "EQUIP-A"
                        iIndex = 0
                    Case "EQUIP-B"
                        iIndex = 1
                    Case "EQUIP-C"
                        iIndex = 2
                End Select[/COLOR]
                Me.TabStrip1.SetFocus
                Me.TabStrip1.Value = iIndex
            End If
        End If
    End With
End Sub

Now, when a selection or matching entry is made from the combobox, focus will shift to the TabStrip, and the corresponding tab will be activated.
 
Upvote 0

Forum statistics

Threads
1,221,808
Messages
6,162,097
Members
451,742
Latest member
JuanMark10

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