View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default Populate one combo box based on the selection of another combo

Suppose brands and models in columns B & C starting in Row 2 like
this:
Ford Focus
Ford Mustang
Chevy Impala
Chevy Malibu

and cell E1 is DropDown1's cell link. Assign this macro to DropDown1.

Sub DropDown1_Change()
Dim iRow As Integer
Dim strBrand As String
Dim strLoc1 As String

'get selection using DropDown1's cell link
strBrand = ActiveSheet.Cells(ActiveSheet.Range("E1") + 1, 1)
iRow = 2
Do
If ActiveSheet.Cells(iRow, 2) = strBrand And iCt = 0 Then
strLoc = ActiveSheet.Cells(iRow, 3).Loc
iCt = 1
End If
If ActiveSheet.Cells(iRow, 2) < strBrand And iCt = 1 Then
strLoc = strLoc & ":" & ActiveSheet.Cells(iRow - 1, 3).Loc
iCt = 2
End If
iRow = iRow + 1
Loop Until iCt = 2
ActiveSheet.Shapes("Drop Down 2").Select
With Selection
.ListFillRange = strLoc
.LinkedCell = ""
.DropDownLines = 8
.Display3DShading = False
End With
ActiveSheet.Range("E1").Select 'unselects DropDown2
End Sub


Hth,
Merjet