Dependent Dropdown (VBA) Again!

Robby19

Board Regular
Joined
Mar 19, 2018
Messages
227
Good day to all of you VBA masters!

Dependent dropdowns in userform are the bane of my existence and make me very.....very sad. But they are super useful and I once again need help in writing the code for it.

So I have a Table laid out like below;

Table1
1aa
1aaa
1aaaa
2bb
2bbb
3cc
3ccc
3cccc
4dd

<TBODY>
</TBODY>

I currently use the following code to populate the first textbox. This textbox will be one of the values from the above table in the first column.
Code:
Private Sub UserForm_Initialize()
    'Get Raid Name from Active Raid
    Me.Txt.Value = Cells(3, 2)
End Sub

So I need the dependent dropdown combobox to look at the Txt.Value and show the corresponding info. For example, if TxtValue = 3c, then the dropdown should populate c, cc, ccc. Can you help?
 
I don't understand what "B3" is for !!!
Surely you are selecting a value in Combobox1 that is then giving you a result in Combobox2.
Where does "B3" come in ????
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I use Data Validation to do the same thing. Maybe you can amend to suit your needs?
I have 3 columns - call them A, B & C.
Whatever I put in A1 combobox determines what appears in B1's combobox list, and so on to C1's list.
Formula in B1 in Data Validation "source" is "=INDIRECT(a1)" without the inverted commas.
Formula in C1 in Data Validation "source" is "=INDIRECT(SUBSTITUTE(A1&B1," ",""))" again without the "
It's been some years since I did this and cant remember everything I needed to make this work but I know there are named ranges which refer to the lists which appear in the dependent drop-downs.
ie. If A is food groups like meat, fruit or vegetables, B might be all the lists like meat= beef, pork, chicken; fruit = apples oranges, etc; veg= beans, peas, pumpkin, potato
C lists would then be types of beef cuts etc etc
So picking meat in A only gives you the options in B of beef chicken or pork and if you choose beef, C will only show rump, sirloin, etc
 
Upvote 0
Prior to your first post instead of having Combobox1, I had a textbox that was linked to B3. As this is autopopulated when the user creates a new worksheet. After reading your post and you suggested I change the textbox to a combobox, that is what I did. HOWEVER, I DO NOT want users to be able to edit the value of B3 nor select a different value from a dropdown. I just want the VBA to use B3 as a reference when looking at Table1 and finding the correct matches.
@keithmct Thank you for the response, but I need this in a VBA userform, not formulas.
 
Upvote 0
This is still not clear !!
From what you say it would appear you don't want "Combobox1" because that would give the "User" the opportunity to use it. !!
So is it correct that you want the Userform to have "Combobox2" that is filled on "opening/or "B3"changing", with values relating to column2 of "table3" in sheet "WorksheetTab" ", based on cell "B3".
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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