Dynamic combo box userform Help

LTSSB

New Member
Joined
Mar 13, 2018
Messages
8
So I've slowly worked my way up to experimenting with VBA. I understand a few basic functions but not enough to help me solve this problem, and so here I am.
smile.gif


I would like to figure out what code I need to make the selections from two dependent combo boxes display a cell range after the command button is hit. (ie: cbo1 = "Text" cbo2 = "Text1" then select additional cells to input in list once button is pressed) I really hope that makes sense but just in case it doesn't, here is a screenshot of sample workbook mocked up to show what I am trying to accomplish


s!An4oRuUYTjkVhClSepOl4QH_dAZ6
https://1drv.ms/u/s!An4oRuUYTjkVhClSepOl4QH_dAZ6

s!An4oRuUYTjkVhClSepOl4QH_dAZ6
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Cross posted https://www.excelforum.com/excel-programming-vba-macros/1224189-dynamic-combo-box-userform-help.html

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Whilst I don't fully understand what you want. This might get you started
Code:
Option Explicit
Private UfDic As Object


Private Sub ComboBox1_AfterUpdate()
   ComboBox2.Value = ""
   ComboBox2.List = Application.Index(UfDic(CDbl(ComboBox1.Value)).keys, 1, 0)
End Sub


Private Sub ComboBox2_AfterUpdate()
   TextBox1.Value = UfDic(CDbl(ComboBox1.Value))(ComboBox2.Value)
End Sub


Private Sub UserForm_Initialize()

   Dim Cl As Range
   Dim RawWs As Worksheet
   
   Set RawWs = Sheets("RawDat")
   Set UfDic = CreateObject("scripting.dictionary")
   For Each Cl In RawWs.Range("B2", RawWs.Range("B" & Rows.Count).End(xlUp))
      If Not UfDic.exists(Cl.Value) Then
         UfDic.Add Cl.Value, CreateObject("scripting.dictionary")
         UfDic(Cl.Value).Add Cl.Offset(, 1).Value, Cl.Offset(, 10).Value
      ElseIf Not UfDic(Cl.Value).exists(Cl.Offset(, 1).Value) Then
         UfDic(Cl.Value).Add Cl.Offset(, 1).Value, Cl.Offset(, 10).Value
      End If
   Next Cl
   
   ComboBox1.List = Application.Index(UfDic.keys, 1, 0)
End Sub
 
Upvote 0
I am sorry I can't seem to correctly word what I'm trying to accomplish. I am and have been for the past 6 hours now, going through various online "training" courses in the hopes that I won't have to ask so many elementary level questions on the subject. But as for this problem in particular I am trying to head down a different path to achieve my goal due to the lack of understanding the syntax. Thank you though for the coding, I will try and implement it soon.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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