Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Listbox value depending on other listbox value

Hi,

I use in 1 form 2 listboxes, one to select a country, and one to select a
city. If the user selects a county, automaticly from the list a default city
shoudl be made visible in the second listbox. At this moment the default is
not set, possible because the value of the first listbox is not yet set in
the worksheet?

How to make this happen?

regards
Gerard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Listbox value depending on other listbox value

Indirect() is the function

example
4 tables.
Table 1, range name COUNTRIES, list is ENGLAND, FRANCE , USA
Table 2, range name ENGLAND, list is London, Norwich, Liverpool, Manchester
Table 3, range name FRANCE, list is Paris, Rheims, Lyon
Table 4, range name USA, list is New York, Los Angeles, Boston, Orlando

in a cell, named SelectedCountry, add data validation, select List and
=Countries
in another cell, SelectedCity, add data validation, choose list and the
source is =INDIRECT(SelectedCountry)

add a CHANGE event to the sheet, that clears SelectedCity if the changed
cell was SelectedCountry

Hope this gives you an idea



http://www.xl-expert.com/IndirectValidation.htm



"noord453" wrote in message
...
Hi,

I use in 1 form 2 listboxes, one to select a country, and one to select a
city. If the user selects a county, automaticly from the list a default
city
shoudl be made visible in the second listbox. At this moment the default
is
not set, possible because the value of the first listbox is not yet set in
the worksheet?

How to make this happen?

regards
Gerard


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 515
Default Listbox value depending on other listbox value

You need to set up a list of towns for each country. Name the list of towns
after the country they relate to. The list of countries you could name
Countries. For each country you would then have a seperate list. Say you
have Argentina, Equador, Poland, Russia, South Africa. The source for
listbox1 would then be Countries.

In your second listbox, indicate the source as =INDIRECT(Listbox1). In this
way, it would read the list from the range name pertaining to that country.

--
HTH

Kassie

Replace xxx with hotmail


"noord453" wrote:

Hi,

I use in 1 form 2 listboxes, one to select a country, and one to select a
city. If the user selects a county, automaticly from the list a default city
shoudl be made visible in the second listbox. At this moment the default is
not set, possible because the value of the first listbox is not yet set in
the worksheet?

How to make this happen?

regards
Gerard

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Listbox value depending on other listbox value

Patrick,

Thanks for your answer. Please let me explain more my challange.

In a form, I want to select a county, this selection is stored in sheet1
cell C3, this cell is named country. In sheet2 cell C5 a vlookup is done to
find a match in a table which looks like this:
=IF(country<"";VLOOKUP(country;'Parameters - lists'!G2:I200;3;FALSE);"")

Where Parameters lists, is a sheet, in which I have stored all the lists.

Regards
Gerard

Country Customer Centre
Netherlands Amsterdam
U.K. Bristol
France Amsterdam
Belgium Bristol
Germany Bonn

In the same form the second listbox must show, the corresponding customer
centre, based on the value of sheet2 cell C5

So I am looking for the command in VB to make this happen because now
because the form is not completed yet, the county value is not set in sheet1
C3, or I am looking for some programming in VB to do the VLOOKUP. The VLOOKUP
command used in Sheet2 C5 is as follows:



"Patrick Molloy" wrote:

Indirect() is the function

example
4 tables.
Table 1, range name COUNTRIES, list is ENGLAND, FRANCE , USA
Table 2, range name ENGLAND, list is London, Norwich, Liverpool, Manchester
Table 3, range name FRANCE, list is Paris, Rheims, Lyon
Table 4, range name USA, list is New York, Los Angeles, Boston, Orlando

in a cell, named SelectedCountry, add data validation, select List and
=Countries
in another cell, SelectedCity, add data validation, choose list and the
source is =INDIRECT(SelectedCountry)

add a CHANGE event to the sheet, that clears SelectedCity if the changed
cell was SelectedCountry

Hope this gives you an idea



http://www.xl-expert.com/IndirectValidation.htm



"noord453" wrote in message
...
Hi,

I use in 1 form 2 listboxes, one to select a country, and one to select a
city. If the user selects a county, automaticly from the list a default
city
shoudl be made visible in the second listbox. At this moment the default
is
not set, possible because the value of the first listbox is not yet set in
the worksheet?

How to make this happen?

regards
Gerard


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
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Filling a listbox depending on font index Trevor[_3_] Excel Programming 0 October 1st 03 08:25 PM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


All times are GMT +1. The time now is 08:10 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"