Add to UserForm ComboBox from a module

jnewlin

New Member
Joined
Aug 2, 2007
Messages
18
I originally set up a sheet with Control Toolbox comboboxes, but would now like to move all of those comboboxes to a userform. I'm having trouble referencing a combobox that is located on a userform from a MODULE. Here is my code that's located IN A MODULE (where the first 3 dots represent more code in the subroutine that's irrelevant:

Sub SpecificGravity()
Dim LRow As Long
Dim LRowSave As Long

...

Sheets("Sheet1").Select
ActiveSheet.Shapes("ComboBox1").Select
Selection.ListFillRange = "'Elasticity'!$B$" & LRowSave & ":$D$" & LRow
End Sub

The above worked fine for populating a combobox located on a sheet.

Instead of filling ComboBox1 located on Sheet1, I want to fill ComboBox3 located in UserForm1. What code would I use? Something like:

UserForm1.ComboBox3.ListFillRange = "'Elasticity'!$B$" & LRowSave & ":$D$" & LRow

and delete the lines:

Sheets("Sheet1").Select
ActiveSheet.Shapes("ComboBox1").Select

This doesn't work.
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

ageren

Board Regular
Joined
Jul 30, 2007
Messages
60
UserForm1.ComboBox3.ListFillRange = "'Elasticity'!$B$" & LRowSave & ":$D$" & LRow

replace your above code with below;

UserForm1.Controls(ComboBox3).Rowsource = "'Elasticity'!$B$" & LRowSave & ":$D$" & LRow


sorry, i can not understand the second part of your enquire :

and delete the lines:

Sheets("Sheet1").Select
ActiveSheet.Shapes("ComboBox1").Select
 

jnewlin

New Member
Joined
Aug 2, 2007
Messages
18
do i need another line?

simply replacing that line of code did not work. I get the message:

"Could not set the RowSource property. Member not found."

ComboBox3 is placed in UserForm1. What am I leaving out?
 

jnewlin

New Member
Joined
Aug 2, 2007
Messages
18
do i need another line?

There is one small error in your answer. You left out the parenthesis. It should look like:

UserForm1.Controls("ComboBox3").RowSource = "'Elasticity'!$B$" & LRowSave & ":$D$" & LRow

It works now, thanks!
 

Watch MrExcel Video

Forum statistics

Threads
1,123,110
Messages
5,599,776
Members
414,337
Latest member
ogoodheart

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
Top