For an example: I used this to allow for State / County selection on a project. This design would work for any situation where your first selection list can be viewed as the 'header row' for a table that list all the options (see attached sheet labeled 'HIDDEN' for my full table).
Both list, require data validation be used. Also, I put the 'heavy lifting' into the name manager in two named formulas:
First list: States of the United States, formula is =HIDDEN!$A$1:INDEX(HIDDEN!$1:$1,COUNTA(HIDDEN!$1:$1))
Second list: to provide Counties for a given state is given by: =INDEX(HIDDEN!$A:$XFD,2,MATCH(VISIBLE!$C$3,HIDDEN!$1:$1,0)):INDEX(HIDDEN!$A:$XFD,COUNTA(INDEX(HIDDEN!$A:$XFD,0,MATCH(VISIBLE!$C$3,HIDDEN!$1:$1,0))),MATCH(VISIBLE!$C$3,HIDDEN!$1:$1,0))
EDIT:
If you want the second value to go away when the first value is changed, you need VBA. Attached is a second example that does this (using the following VBA in the Sheet2 ('VISIBLE') module.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim YES_NO As Integer
Dim possibleCounties As Range, found As Range
On Error GoTo PROC_ERR
Application.EnableEvents = False
'State Changed - Clear County Entry IF that county is not part of the new state's list'
If Not Intersect(Target, Sheet2.Range("C3")) Is Nothing Then
'Check State Name'
Set found = Sheet1.Range("1:1").Find(WHAT:=Target.Value, LookIn:=xlValues, Lookat:=xlWhole)
If found Is Nothing Then
MsgBox ("State Name invalid. Use pick-list if unsure of spelling." & Chr(13) & Chr(13) & " Entry, " & Sheet1.Range("B10").Value & ", not found in state list.")
Sheet2.Range("C3").ClearContents
Sheet2.Range("C5").ClearContents
Application.EnableEvents = True
Exit Sub
ElseIf found = "" Then
Sheet2.Range("C5").ClearContents
Application.EnableEvents = True
Exit Sub
End If
If found Is Nothing Then
Sheet2.Range("C5").ClearContents
Else
'State was found - check check county.'
Set found = found.EntireColumn.Find(WHAT:=Sheet2.Range("C5").Value, LookIn:=xlValues, Lookat:=xlWhole)
If found Is Nothing Then Sheet2.Range("C5").ClearContents
End If
End If '
PROC_ERR:
Application.EnableEvents = True
If Err.Description <> "" Then MsgBox ("ERROR: " & Err.Description)
End Sub
Bookmarks