Problems creating multiple dropdown lists in one userform

jameslytle

New Member
Joined
Jul 30, 2018
Messages
21
Need help.

I am trying to create a userform that has (Currently) four dropdown lists but I am having issues once I add the third and fourth list.

In Excel I created a name for each list of items to be used i the dropdown lists (i.e. List Name - Eye for a list of eye colors and Name - Hair for hair colors).

My problem is that I have four drop down lists. Everything was working fine until I tried to add the third and fourth drop down lists. The first two lists worked just fine but the third and fourth one I get an error message (Run time Error '1004' Method 'range' of object '_Global' failed). Now if I take the range listed for list number 2 and put it in list number 3 it works fine by showing the drop down list for number 2 on number 3 as well.

Below is a copy of the programming that I have set up for the userform so far.

Please tell me what I am doing wrong.

Thanks.

Private Sub UserForm_Initialize()
With PhenoCombo
.List = Range(PhenoType).Value
.Value = "Human"
End With

With GenderCombo
.List = Range(Gender).Value
End With

With EyeCombo
.List = Range(Eye).Value
End With

With HairCombo
.List = Range(Hair).Value
End With


End Sub

Jim
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Thanks for the response Alansidman but it does not help me as I am not trying to create dependent combo boxes. Each combo box is separate and has its own list assigned to it. It is just that for some reason the third and fourth ones I keep getting the error that I mentioned above and it does not show the dropdown list. The coding for the third and fourth list is exactly the same as for the second list, just linking to a different combobox and linking to a different named list.
 
Upvote 0
Named ranges need to go in quotes like
Code:
Private Sub UserForm_Initialize()
With PhenoCombo
.List = Range("PhenoType").Value
.Value = "Human"
End With
 
Upvote 0
Thanks Fluff,

That solved my problems. That being said why did my first two lists work correctly as they also did not have the quotes but did not give me any errors when I ran them?

Jim
 
Upvote 0
The only reason why they worked, that I can think of, is that you have them set as public variables
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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