Hi There,
Your question:-
if a1="x" dropdown in a2 should be US,CANADA,MEXICO
if a1="y" dropdown in a2 should be CHINA,JAPAN,INDIA,KOREA
This can be done by VBA.
Step 1: Enter first three cities in one coloumn, take an example it is in
cell F4 to F6
F4 = "US"
F5 = "CANADA"
F6 = "MAXICO"
(Note:- You are doing this stuff in Sheet1, default sheet)
Step 2: Go to VBA, open the Project Window, and then click the Sheet1 to
open its code window.
Step3: copy below code and try out
Note:- Make sure that you entered three cities in F4, F5, and F6 cell
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ObjCell As Range
Dim ObjDataRangeStart As Range
Dim ObjDataRanceEnd As Range
If Target.Row = 2 And Target.Column = 1 Then
Set ObjCell = ActiveSheet.Cells(1, 2)
Set ObjDataRangeStart = ActiveSheet.Cells(4, 6)
Set objDataRangeEnd = ActiveSheet.Cells(6, 6)
With ObjCell.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, Formula1:="=" & ObjDataRangeStart.Address & ":" &
objDataRangeEnd.Address
.IgnoreBlank = True
.InCellDropdown = True
.ErrorTitle = "Warning"
.ErrorMessage = "Select from list"
.ShowError = True
End With
End If
End Sub
Step 4: Press Ctrl + S to save your written code, and then go back to Excel.
Step 5: Now core part is done, click the cell A1 and enter your value
Note: Enter "x" in A1 cell and hit enter, it will show u the list of cities
in a dropdown list of A2 cell.
Good luck,
Sanjay