![]() |
Linking multiple combo boxes
Hi All
Does anyone know where I can get the code to link several combo boxes . so if the user selects the first box it will populate the second box with specific values and if the user selects the second box it will populate the third box with specific values. any help will be greatly appreciated Regards Subs |
Linking multiple combo boxes
Subs,
Private Sub ComboBox1_Change() ComboBox2.Text = ComboBox1.Text ComboBox2.Value = ComboBox1.Value End Sub Alex A. (If this was helpful please click the Yes button!) "Subs" wrote: Hi All Does anyone know where I can get the code to link several combo boxes . so if the user selects the first box it will populate the second box with specific values and if the user selects the second box it will populate the third box with specific values. any help will be greatly appreciated Regards Subs |
Linking multiple combo boxes
Private Sub ComboBox1_Change() Set rng=range(Combobox1.value & "_Models") combobox2.clear For each cell in rng combobox2.additem cell.value next cell End Sub "Subs" wrote: Hi All Does anyone know where I can get the code to link several combo boxes . so if the user selects the first box it will populate the second box with specific values and if the user selects the second box it will populate the third box with specific values. any help will be greatly appreciated Regards Subs |
Linking multiple combo boxes
Hi,
Sorry .. finger trouble on first post. Hope the following example is what you want i.e selection from one combobox will populate another combobox with a list of data. Combobox1 is initiliazed with list of car manufacturers based on named range "Manufacturers". When combobox1 is selected, combobox2 is loaded with models from named range; if manufacturer is "Ford" then named range is "Ford_Models". Similarly, combobox3 is loaded with colours for a given model e.g. named range "Fiesta_Colours" (UK car models here!) You could use arrays of named ranges in combination with the ListIndex of a combobox (or both) to get the date to be loaded.I personally think named ranges are the best way of organising the data. HTH Private Sub Combobox1_Change() Dim rng As Range, cell As Range ' Set combobox2 with list of models for given manufacturer Set rng = Range(ComboBox1.Value & "_Models") ComboBox2.Clear For Each cell In rng ComboBox2.AddItem cell.Value Next cell End Sub Private Sub Combobox2_Change() Dim rng As Range, cell As Range ' Set combobox3 with list of colours for given model Set rng = Range(ComboBox2.Value & "_Colours") ComboBox3.Clear For Each cell In rng ComboBox3.AddItem cell.Value Next cell End Sub Private Sub Userform_Initialize() Dim rng As Range, cell As Range Set rng = Range("Manufacturers") For Each cell In rng ComboBox1.AddItem cell.Value Next cell End Sub "Subs" wrote: Hi All Does anyone know where I can get the code to link several combo boxes . so if the user selects the first box it will populate the second box with specific values and if the user selects the second box it will populate the third box with specific values. any help will be greatly appreciated Regards Subs |
Linking multiple combo boxes
Subs,
I guess you need the item selected in ComboBox1 to be added to the list of ComboBox2??? But do you want the list in combobox2 to grow with each selection of combobox1???? In that case the he syntax would be something like this- Private Sub ComboBox1_Change() ComboBox2.AddItem ComboBox1.Value 'Or ComboBox1.Text End Sub We really need more information here. "Subs" wrote: Hi All Does anyone know where I can get the code to link several combo boxes . so if the user selects the first box it will populate the second box with specific values and if the user selects the second box it will populate the third box with specific values. any help will be greatly appreciated Regards Subs |
All times are GMT +1. The time now is 06:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com