Auto-filling multiple drop-down menus based on selection of one drop-down

Johnstone

New Member
Joined
Nov 12, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I will preface this question noting that I am new to VBA scripts and macros so I may be missing an obvious solution :)

I have a form I am building out with a mix of drop-down and manual entry fields. I need several of the fields to auto-fill based on the choice of a field selection at the top of the form.

My initial thought was to create a Macro where I record the selections I need for each drop down and manually input the response for the text fields. When I recorded the Macro and assigned it to a button to test, the manual text fields filled in as expected but the drop-down fields did not fill out at all, they stayed blank. Is there a trick to getting the Macro to select options from a drop-down menu?

I have looked through the threads here on the forum as well as multiple videos and articles online but have not found a Macro or VBA script that has worked.

Thank you in advance for any recommendations
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Is this form a userform or a collection of controls on a sheet?
If it's a userform (by that name) and the control is named ComboBox1 then userform.ComboBox1.Value = 5 ought to set the combo value to 5. However, using that approach you can set the value to anything, even if it's not in the list, and you may not want that to be possible.
Or maybe your issue is that your combo list is not getting populated. It's not clear what the issue is.

EDIT - to prevent setting a value that is not in the list you can make use of the ListIndex property if you know those values. This sets the combo to the first list item: userform.ComboBox1.ListIndex = 0
 
Last edited:
Upvote 0
Is this form a userform or a collection of controls on a sheet?
If it's a userform (by that name) and the control is named ComboBox1 then userform.ComboBox1.Value = 5 ought to set the combo value to 5. However, using that approach you can set the value to anything, even if it's not in the list, and you may not want that to be possible.
Or maybe your issue is that your combo list is not getting populated. It's not clear what the issue is.

EDIT - to prevent setting a value that is not in the list you can make use of the ListIndex property if you know those values. This sets the combo to the first list item: userform.ComboBox1.ListIndex = 0
It is not a userform, I built out the drop-down list through the data validation tab and selecting a range of cells from my drop-down list worksheet. Do you know if it is possible to record a macro that will select the required value from the drop-down list?
 
Upvote 0
Do you want something like this? Where the options in the dropdown are dependent on the value of another cell?

Book2
ABCDEF
1Type1
2123
3DropdownOrangeOrangePineappleCoconut
4BananaBlueberryWatermelon
5AppleStrawberryPeach
Sheet1
Cells with Data Validation
CellAllowCriteria
B3List=INDEX(D3:F5,,B1)
B1List=$D$2:$F$2
 
Upvote 0
Do you want something like this? Where the options in the dropdown are dependent on the value of another cell?

Book2
ABCDEF
1Type1
2123
3DropdownOrangeOrangePineappleCoconut
4BananaBlueberryWatermelon
5AppleStrawberryPeach
Sheet1
Cells with Data Validation
CellAllowCriteria
B3List=INDEX(D3:F5,,B1)
B1List=$D$2:$F$2
That might be an option! I will play with that and see if I can get that to work :) Thank you
 
Upvote 0
Is there a trick to getting the Macro to select options from a drop-down menu?
AFAIK, what appears in a cell (seems like you're calling that a "field") after you've chosen a list value is simply the contents of the cell itself. In other words, you probably could simply assign a value from the list into the cell.

If dependency (aka cascading combos) is what you're after then perhaps you have a solution.
 
Upvote 0

Forum statistics

Threads
1,224,872
Messages
6,181,500
Members
453,047
Latest member
charlie_odd

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