Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox list reliant on the entry from a different ComboBox
I have a UserForm with 2 different ComboBoxes. The first picks up a list of
countries from sheet2. The second will give a list of customers from the country selected from box 1. The list of customer names is in one list on sheet2 containing all customers from each country. The country name is included along side the customer name. I have tried for hours to get this right but nothing seems to work, please help. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox list reliant on the entry from a different ComboBox
Private Sub Combobox1_Click()
Dim sCountry as String sCountry = Combobox1.Value Combobox2.RowSource = "" Combobox2.Clear for each cell in Worksheets("Sheet2").Range("A2:A50") if lcase(cell.offset(0,1).Value) = lcase(sCountry) then Combobox2.AddItem cell.Value end if Next End Sub -- Regards, Tom Ogilvy "ndm berry" wrote in message ... I have a UserForm with 2 different ComboBoxes. The first picks up a list of countries from sheet2. The second will give a list of customers from the country selected from box 1. The list of customer names is in one list on sheet2 containing all customers from each country. The country name is included along side the customer name. I have tried for hours to get this right but nothing seems to work, please help. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox list reliant on the entry from a different ComboBox
Thanks for the help but unfortunately I didn't give enough information before.
The code works but I need the customer number AND name in ComboBox2 (so 2 columns required) and the list of customers is dynamic so the range of the list will be constantly changing. "Tom Ogilvy" wrote: Private Sub Combobox1_Click() Dim sCountry as String sCountry = Combobox1.Value Combobox2.RowSource = "" Combobox2.Clear for each cell in Worksheets("Sheet2").Range("A2:A50") if lcase(cell.offset(0,1).Value) = lcase(sCountry) then Combobox2.AddItem cell.Value end if Next End Sub -- Regards, Tom Ogilvy "ndm berry" wrote in message ... I have a UserForm with 2 different ComboBoxes. The first picks up a list of countries from sheet2. The second will give a list of customers from the country selected from box 1. The list of customer names is in one list on sheet2 containing all customers from each country. The country name is included along side the customer name. I have tried for hours to get this right but nothing seems to work, please help. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox list reliant on the entry from a different ComboBox
Private Sub Combobox1_Click()
Dim sCountry as String sCountry = Combobox1.Value Combobox2.RowSource = "" Combobox2.Clear Combobox2.ColumnCount = 2 With Worksheets("Sheet2") set rng = .range(.cells(2,1),.cells(2,1).End(xldown)) End With for each cell in rng if lcase(cell.offset(0,1).Value) = lcase(sCountry) then Combobox2.AddItem cell.Value combobox2.List(combobox2.Listcount-1,1) = cell.offset(0,2).value end if Next End Sub Change the references to use the appropriate locations. I assume Customer name in A country in B customer number in C all on sheet2 -- Regards, Tom Ogilvy "ndm berry" wrote in message ... Thanks for the help but unfortunately I didn't give enough information before. The code works but I need the customer number AND name in ComboBox2 (so 2 columns required) and the list of customers is dynamic so the range of the list will be constantly changing. "Tom Ogilvy" wrote: Private Sub Combobox1_Click() Dim sCountry as String sCountry = Combobox1.Value Combobox2.RowSource = "" Combobox2.Clear for each cell in Worksheets("Sheet2").Range("A2:A50") if lcase(cell.offset(0,1).Value) = lcase(sCountry) then Combobox2.AddItem cell.Value end if Next End Sub -- Regards, Tom Ogilvy "ndm berry" wrote in message ... I have a UserForm with 2 different ComboBoxes. The first picks up a list of countries from sheet2. The second will give a list of customers from the country selected from box 1. The list of customer names is in one list on sheet2 containing all customers from each country. The country name is included along side the customer name. I have tried for hours to get this right but nothing seems to work, please help. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox list reliant on the entry from a different ComboBox
Thank you very much!
"Tom Ogilvy" wrote: Private Sub Combobox1_Click() Dim sCountry as String sCountry = Combobox1.Value Combobox2.RowSource = "" Combobox2.Clear Combobox2.ColumnCount = 2 With Worksheets("Sheet2") set rng = .range(.cells(2,1),.cells(2,1).End(xldown)) End With for each cell in rng if lcase(cell.offset(0,1).Value) = lcase(sCountry) then Combobox2.AddItem cell.Value combobox2.List(combobox2.Listcount-1,1) = cell.offset(0,2).value end if Next End Sub Change the references to use the appropriate locations. I assume Customer name in A country in B customer number in C all on sheet2 -- Regards, Tom Ogilvy "ndm berry" wrote in message ... Thanks for the help but unfortunately I didn't give enough information before. The code works but I need the customer number AND name in ComboBox2 (so 2 columns required) and the list of customers is dynamic so the range of the list will be constantly changing. "Tom Ogilvy" wrote: Private Sub Combobox1_Click() Dim sCountry as String sCountry = Combobox1.Value Combobox2.RowSource = "" Combobox2.Clear for each cell in Worksheets("Sheet2").Range("A2:A50") if lcase(cell.offset(0,1).Value) = lcase(sCountry) then Combobox2.AddItem cell.Value end if Next End Sub -- Regards, Tom Ogilvy "ndm berry" wrote in message ... I have a UserForm with 2 different ComboBoxes. The first picks up a list of countries from sheet2. The second will give a list of customers from the country selected from box 1. The list of customer names is in one list on sheet2 containing all customers from each country. The country name is included along side the customer name. I have tried for hours to get this right but nothing seems to work, please help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How Do I Get A ComboBox To Add Entry To It's List If Not In List | Excel Programming | |||
Validating entry in ComboBox | Excel Discussion (Misc queries) | |||
Using a ComboBox for Data Entry into a Cell | Excel Programming | |||
Validate Combobox entry | Excel Programming | |||
Combobox - add manual entry to future list | Excel Programming |