question about multipage & initialize userform

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hello i work a program and if i insert userform contain more than multipage on one userform but i face a problem about run code what existed in initialize userform so i have about four multipages contain one combobox for every multipage it show the item only in first multipage but not show for the rests multipage i no know if there is possible do that for all multipage or i have to insert many userform to work it

this is my code in initialize
VBA Code:
Private Sub UserForm_Initialize()
ComboBox1.RowSource = "CODES!" & Sheets("CODES").Range("A5", Sheets("CODES").Range("A65536").End(xlUp)).Address
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Here is a example of One Mutipage on a Userform with 2 Multipage pages
A multipage can have several Multipage pages Like a workbook have several Worksheets

The Comboboxes are name differently and get their values from different sheets and different Ranges.

Do not use RowSource
VBA Code:
Private Sub UserForm_Initialize()
'Modified  12/11/2020  3:55:35 PM  EST
Dim Lastrowa As Long
Dim Lastrowb As Long
Lastrowa = Sheets("Alpha").Cells(Rows.Count, "A").End(xlUp).Row
Lastrowb = Sheets("Bravo").Cells(Rows.Count, "B").End(xlUp).Row

MultiPage1.Page1.ComboBox1.List = Sheets("Alpha").Range("A1:A" & Lastrowa).Value
MultiPage1.Page2.ComboBox2.List = Sheets("Bravo").Range("B1:B" & Lastrowb).Value

End Sub
 
Upvote 0
thanks for your replying actually i was wrong about number the combo box it should 2 in page 2 and 3 in page3 I tested your code and I amended a little but it gives me error

Object Doesn’t Support This Property or Method​

the row source should be one column a and the same sheet
VBA Code:
Private Sub UserForm_Initialize()
Dim Lastrowa As Long
Lastrowa = Sheets("codes").Cells(Rows.Count, "A").End(xlUp).Row
MultiPage1.Page1.ComboBox1.List = Sheets("codes").Range("A1:A" & Lastrowa).Value
MultiPage1.Page2.ComboBox2.List = Sheets("codes").Range("A1:A" & Lastrowa).Value
End Sub
and another question I have each page on userform about 10 combobox how can I do the code by array you know to write about 10 lines into code it takes more time
 
Upvote 0
thanks for your replying actually i was wrong about number the combo box it should 2 in page 2 and 3 in page3 I tested your code and I amended a little but it gives me error

Object Doesn’t Support This Property or Method​

the row source should be one column a and the same sheet
VBA Code:
Private Sub UserForm_Initialize()
Dim Lastrowa As Long
Lastrowa = Sheets("codes").Cells(Rows.Count, "A").End(xlUp).Row
MultiPage1.Page1.ComboBox1.List = Sheets("codes").Range("A1:A" & Lastrowa).Value
MultiPage1.Page2.ComboBox2.List = Sheets("codes").Range("A1:A" & Lastrowa).Value
End Sub
and another question I have each page on userform about 10 combobox how can I do the code by array you know to write about 10 lines into code it takes more time
When I run your code it works for me. Are you sure you have a sheet named "codes"

And you said:
and another question I have each page on userform about 10 combobox how can I do the code by array you know to write about 10 lines into code it takes more time

I think first we should get what you have working first.

So are you loading all the comboboxes on all of the pages with data from the same sheet and same range. Which appears to always be column A
 
Upvote 0
When I run your code it works for me. Are you sure you have a sheet named "codes"
yes I'm sure about sheet named "codes" and i tested again it gives me error
I think first we should get what you have working first.
I have on userform page3 = cmobobox from 2 to 30 and page 4 = combobox from 31 to 45
So are you loading all the comboboxes on all of the pages with data from the same sheet and same range. Which appears to always be column A
yes you're right
 
Upvote 0
You need some code like this:
It refers to The Multipage and the Page on the userform and the Combobox

VBA Code:
Private Sub CommandButton2_Click()
'Modified  12/12/2020  12:01:47 PM  EST
Cells(1, 2).Value = MultiPage1.Page1.ComboBox1.Value
Cells(1, 3).Value = MultiPage1.Page2.ComboBox2.Value

End Sub
 
Upvote 0
This script will load all the Comboboxes in your Userform with the values in Column A of sheet named "Codes"
VBA Code:
Private Sub CommandButton2_Click()
'Modified  12/12/2020  1:40:34 PM  EST
Dim Lastrow As Long
Lastrow = Sheets("Codes").Cells(Rows.Count, "A").End(xlUp).Row
Dim ctrl As MSForms.Control
 For Each ctrl In Me.Controls
    Select Case True
        Case TypeOf ctrl Is MSForms.ComboBox
            ctrl.List = Sheets("Codes").Range("A1:A" & Lastrow).Value
    End Select
Next ctrl
End Sub
 
Upvote 0
sorry what I say you but I have to make also based on column b ,c the same sheet("code")
the combobox from 1 to 10 based on column a and from 11 to 20 based on column b and from 21 to 30 based on column c
sorry again I don't mentioned from the beginning
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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