Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do I Get A ComboBox To Add Entry To It's List If Not In List Minitman[_4_] Excel Programming 15 October 8th 05 03:28 AM
Validating entry in ComboBox LAF Excel Discussion (Misc queries) 0 September 29th 05 08:45 PM
Using a ComboBox for Data Entry into a Cell Jon Turner[_2_] Excel Programming 4 May 27th 05 09:53 PM
Validate Combobox entry MBlake Excel Programming 5 May 4th 05 08:39 PM
Combobox - add manual entry to future list cornishbloke[_23_] Excel Programming 3 January 16th 04 01:19 PM


All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"