Dependent Combo Box in multipage

haseft

Active Member
Joined
Jun 10, 2014
Messages
321
Hi,
In a usefrom a have a multipage with 7 pages.
In page 5, 6 and 7 there is a combobox and they populate from the same range in sheet1 (working fine).
I want combobox in page 5, 6 and 7 will show the same item/row when I go back and forth between these tre pages.
Its not workning,
Thansk for hep,

VBA Code:
Dim MyIndex As Integer  ' in UserForm_Initialize()
'----------------------------------

Private Sub Page5ComboBox1_Change()
  MyIndex = Page5ComboBox1.ListIndex
End Sub

Private Sub Page6ComboBox1_Change()
  MyIndex = Page6ComboBox1.ListIndex
End Sub

Private Sub Page7ComboBox1_Change()
  MyIndex  = Page7ComboBox1.ListIndex
End Sub
'----------------------------------

Private Sub MultiPage1_Change()
  Select Case MultiPage1.SelectedItem.Index
    Case 4 ' = Page5
       Page5ComboBox1.ListIndex = MyIndex
    Case 5 ' = Page6
       Page6ComboBox1.ListIndex = MyIndex
    Case 6 ' = Page7
       Page7ComboBox1.ListIndex = MyIndex
  End Select
End Sub
'----------------------------------
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello Haseft,

please use below code:

VBA Code:
Option Explicit
Dim selItem As String, selectedPage As Byte

Private Sub cbo5_Change()
     selItem = cbo5.Value
End Sub

Private Sub cbo6_Change()
     selItem = cbo6.Value
End Sub

Private Sub cbo7_Change()
     selItem = cbo7.Value
End Sub

'Multipage change event
Private Sub MultiPage1_Change()
    selectedPage = MultiPage1.SelectedItem.Index
    'MsgBox selectedPage
    Select Case selectedPage
        Case 4 ' = Page5
           cbo5.Value = selItem
        Case 5 ' = Page6
           cbo6.Value = selItem
        Case 6 ' = Page7
           cbo7.Value = selItem
  End Select
End Sub

Thanks,
Saurabh
 
Upvote 0
Solution
Thanks Saurabhj,
its not working

where should I put these linse:
VBA Code:
Option Explicit
Dim selItem As String, selectedPage As Byte
in in UserForm_Initialize() or in a Modul?
 
Upvote 0
I want combobox in page 5, 6 and 7 will show the same item/row when I go back and forth between these tre pages.
Untested, maybe this:
VBA Code:
Private Sub MultiPage1_Change()
  Select Case MultiPage1.SelectedItem.Index
    Case 4,5,6
       Page5ComboBox1.ListIndex = MyIndex

       Page6ComboBox1.ListIndex = MyIndex

       Page7ComboBox1.ListIndex = MyIndex
  End Select
End Sub
 
Upvote 0
Thanks Saurabhj,
its not working

where should I put these linse:
VBA Code:
Option Explicit
Dim selItem As String, selectedPage As Byte
in in UserForm_Initialize() or in a Modul?
In the userform on the top. These are module level variables so we are not declaring these variables inside any event.

I have tested the same. It's working as required.

(See attached)
 

Attachments

  • code.PNG
    code.PNG
    72.2 KB · Views: 5
Upvote 0
Thansk Saurabhj,
I tested in a new workbok and it work great.
There is somthing wrong with my original Project, I will check it and find the problem.
Thanks igain.

Akuini: I did not tested your codes yet.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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