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.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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
 
Upvote 0
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?
 
Upvote 0
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!
 
Upvote 0

Forum statistics

Threads
1,214,878
Messages
6,122,062
Members
449,064
Latest member
scottdog129

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