#1
|
|||
|
|||
Help! - multiselect userform listbox with dependent drop down
Hello,
I am attempting to create a content control drop down that has options dependent on selections made on a multiselect userform listbox. I have a functioning listbox but cannot figure out how to create either additional dependent listboxes or drop downs. I have attached a copy of my current progress. The existing listbox will end up with more than 25 options and the same goes for the dependent drop down I am hoping for. I have searched existing threads and cant seem to piece this together. Any help or direction would be greatly appreciated! |
#2
|
|||
|
|||
It is not clear to me what you are attempting to do. Content Control dropdown lists are not capable of multiple selections. About all you can do is display a userform with the CC entry event and use a userform listbox to make multiple selections. This appears to be what you have done in your document.
This may not be the answer you are looking for but you might find it helpful: (Pseudo Multi-Select Dropdown Content Controls |
#3
|
|||
|
|||
Thanks for looking and the link, I think it was one of the resources I used to get this far. The multiselect portion is working but I am trying create another CC dropdown that would populate different lists based on the selections of the existing userform. The additional drop down I am trying to get working would not need to be multiselect as well, just a secondary list dependent on the userform.
If I can make this work I would ultimately like another CC dropdown as well that would populate based on the choice in the first drop down. So hopefully I will end up with three levels of selections. The first being the existing userform, then a dependent drop down, followed by another dependent drop down. I recently found your website (which is awesome!) and the only thing I could find close to this would require an outside data source, such as excel or another word doc. I was hoping to keep this all contained within the VBA. Thank you again for any insight you can provide! |
#4
|
|||
|
|||
See attached. Not sure if that is you goal or not.
|
#5
|
|||
|
|||
That works! you're awesome! Thank you so much!
|
#6
|
|||
|
|||
Hello again!
I am so close to having this figured out and greatly appreciate everyone on this site. I think I may need a bit more help to get this document where I need it. I have a drop down CC dependent on a multiselect listbox and I have added an additional drop down I would like to be dependent on the first dependent drop down. The dropdown titled "What line should say" should be dependent on the selection of drop down titled "Line" which is currently dependent on the listbox titled "Section". Can you help with the coding to make this work? Another concern I have is with duplicate display names. Is it possible to have the same choice for multiple different listbox selections? I attempted to add the same choice to the drop down for different cases and received a runtime error, "An entry with the same display name already exists". Can this be ignored/avoided? I would like some choices to be possible for multiple different listbox cases but not actually duplicate on the drop down. Thank you again! |
#7
|
|||
|
|||
Huzzah! I think I managed to work out all the dependent drop downs!
Still curious about the run time error however. Any way to enable repeat display names? I thought the value listed next to each display name would make them unique if they were all different, but I guess not? |
#8
|
|||
|
|||
You can not have to similar "display" or two similar "values" defined for a content control DDL.
You could always use a userform, like you have learned to do for the multi-select list. I am having trouble understanding why you would want two or more list items with the same value? |
#9
|
|||
|
|||
Well thank you for enlightening me.
The first drop down (which is dependent on the userform) would have options that are unique but also some options that are repeated. As an example, say I have a dropdown with options that are car models and a dependent dropdown that lists features. Some car models would have the same features and the features need to be listed more than once under different models. I hope that makes sense? Perhaps there is some way to reuse a display name? maybe use the associated value to reference it again on another case? Thank you again for your time and expertise! |
#10
|
|||
|
|||
Sorry but that doesn't make sense. If you have a multi-select dropdown that gives the user the option to pick a car model and your list includes Ford Escort, Toyota Camry and Nisan Maxima.
Your user picks the Ford and the Toyota. The Ford has auto pilot and tires, the Toyota has warp drive and tires. Your dependent list would include Ford AutoPilot Toyota Warpdrive Tires What would the the point of Ford AutoPilot Tires Toyota Warpdrive Tires If there is a point that I am missing then 1): Ford AutoPilot Ford Tires Toyota Warpdrive Toyota Tires or b): Use a userform with a mutli-select listbox as a pseudo content control. |
#11
|
|||
|
|||
I apologize if I am being dense.
From your example if the user selects both Ford and Toyota then the dependent list should list Auto Pilot, Warp Drive, and Tires. This is the result I want. But what if the user selects only one model? Wouldn't Tires only be "saved" under one of the models cases and not be available to both individually? If the model is selected individually: Ford>Auto Pilot, Tires Toyota>Warp drive, Tires If multiple models are selected: Ford & Toyota>Auto pilot, Warp Drive, Tires I don't want Tires listed twice if both models are selected, just have Tires be available to both modules individually AND if both models are selected together. Is the only way to accomplish this to have a third case which which is Ford and Toyota and have its own list? This is the best I could come up with and would be very difficult in the end. Case "Ford" DropdownListEntries.Add "Auto Pilot" DropdownListEntries.Add "Tires" Case "Toyota" DropdownListEntries.Add "Warp Drive" DropdownListEntries.Add "Tires" Case "Ford", "Toyota" DropdownListEntries.Add "Auto Pilot" DropdownListEntries.Add "Warp Drive" DropdownListEntries.Add "Tires" Thank you as always! |
#12
|
|||
|
|||
If this stuff was easy, anyone could do it. Here is something for you to contemplate:
Code:
Sub ScratchMacro() 'A basic Word Macro coded by Gregory K. Maxey Dim arrFordOptions() As String Dim arrToyotaOptions() As String Dim arrNissanOptions() As String Dim oColOptions As New Collection Dim lngIndex As Long Dim bFord As Boolean, bToy As Boolean, bNis As Boolean arrFordOptions() = Split("Auto Pilot|Tires|mirrors", "|") arrToyotaOptions() = Split("Warp Drive|Tires|headlights", "|") arrNissanOptions() = Split("Rear facing seat|Tires|taillights", "|") 'Let's assume the user selects Ford and Toyota so: bFord = True: bToy = True 'Many times with VBA, errors can be your friend: On Error Resume Next If bFord Then For lngIndex = 0 To UBound(arrFordOptions) oColOptions.Add arrFordOptions(lngIndex), arrFordOptions(lngIndex) Next End If If bToy Then 'One of the Toyota options "tires" duplicates a Ford option. For lngIndex = 0 To UBound(arrToyotaOptions) 'When the tires option is hit the error is thrown because each item in the collection must have a unique key. oColOptions.Add arrToyotaOptions(lngIndex), arrToyotaOptions(lngIndex) Next End If If bNis Then For lngIndex = 0 To UBound(arrNissanOptions) oColOptions.Add arrNissanOptions(lngIndex), arrNissanOptions(lngIndex) Next End If 'Populate your dependent list with the collection items For lngIndex = 1 To oColOptions.Count Debug.Print oColOptions.Item(lngIndex) Next lngIndex lbl_Exit: Exit Sub End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Userform multiselect listbox populate | trevorc | Excel Programming | 1 | 12-03-2018 02:49 PM |
Multiselect listbox - custom outlook form | A_Balt | Outlook | 0 | 07-19-2018 09:36 AM |
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word | marksm33 | Word VBA | 3 | 01-15-2015 07:55 PM |
This is a Userform LIstbox queston: A variable does not set to the value of a listbox | CatMan | Excel | 1 | 08-08-2014 09:41 AM |
Data from Excel to Listbox multiselect to Word | marksm33 | Word VBA | 2 | 02-18-2014 08:30 AM |