Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If A2 =X from list V then B2= Y from list W


I need help with this situation.
lets stay column A has drop down menu where I can select 5 countries,
depending on what country I select in A I want the corresponding cell
in column B to allow me to select only from a list of cities of the
country selected in A.

Thank you



--
AERIF
------------------------------------------------------------------------
AERIF's Profile:
http://www.excelforum.com/member.php...o&userid=28395
View this thread: http://www.excelforum.com/showthread...hreadid=479867

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default If A2 =X from list V then B2= Y from list W

Hi,
Look at the following which explains how to create dependent Data
Validation lists.

www.contextures.com/xlDataVal02.html

HTH

"AERIF" wrote:


I need help with this situation.
lets stay column A has drop down menu where I can select 5 countries,
depending on what country I select in A I want the corresponding cell
in column B to allow me to select only from a list of cities of the
country selected in A.

Thank you



--
AERIF
------------------------------------------------------------------------
AERIF's Profile:
http://www.excelforum.com/member.php...o&userid=28395
View this thread: http://www.excelforum.com/showthread...hreadid=479867


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If A2 =X from list V then B2= Y from list W


Hello Aerif,

This code uses a Drop Down box that holds the names of the countrie
and List Box that will display the cities. Selecting a country load
the List Box with the cities you want.

You need to set the Drop Down list's macro to SelectCountry to make i
work. I was uncertain if you wanted to return the city that wa
selected to a particular cell. Let me know and I can change that fo
you.

Copy and paste this code into the declarations section of the Workshee
the Drop Down list and List Box are on. You need to change the number
of the Drop Down and List Box to match those on your worksheet. The
are marked in red. Also the you will need to change the cities list
You can add as many country/city combinations as you need. Just follo
the format as it is shown.


Code
-------------------
Sub SelectCountry()

With Shapes("Drop Down 4").ControlFormat
If .ListIndex < 0 Then
LoadListBox (.List(.ListIndex))
Else
Shapes("List Box 6").ControlFormat.RemoveAllItems
End If
End With

End Sub
__________________________________________________ _
Sub LoadListBox(ByVal Country As String)

Dim Cities

Select Case Country
Case Is = "US"
Cities = Array("New York", "Boston", "Atalnta", "Baton Rouge", "Jackson")
Case Is = "Mexico"
Cities = Array("Mexico City", "Jalisco", "Tijuana", "Cabo San Lucas", "Acapulco")
End Select

Shapes("List Box 6").ControlFormat.RemoveAllItems
Shapes("List Box 6").OLEFormat.Object.List = Cities


End Sub

-------------------

--
Leith Ros

-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=47986

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
Comparing List A to List B and add what's missing from List B Gilbert Excel Discussion (Misc queries) 2 July 20th 09 11:18 PM
create new list from list A, but with exclusions from a list B Harold Good Excel Worksheet Functions 3 April 11th 08 11:23 PM
validation list--list depends on the selection of first list Michael New Users to Excel 2 April 27th 06 10:23 PM
list 1 has 400 names List 2 has 4000. find manes from list 1 on 2 Ed Excel Worksheet Functions 5 September 12th 05 09:48 AM
find names on list 1 in list 2. list 1 4000 names list 2 400 name Ed Excel Worksheet Functions 1 September 4th 05 12:48 AM


All times are GMT +1. The time now is 06:42 PM.

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"