I have already posted about a similar subject at For each loop with data validation lists
I am using data validation for two drop downs and then I am using data validation with =INDEX('2. Sheet2'!$G$2:$AC$50;;MATCH($G$3;'2. Sheet2'!$G$1:$AC$1;0)) for my two dependent drop downs.
I have tried named ranges for my dropdowns w/o success.
I am unable to get a for each loop to loop through all possible combinations of dropdown1, dropdown2 vs. dropdown3, dropdown4.
I have tried all the code in the earlier thread and I am unable to tweak it myself and I have spent a lot of time trying without success. I am learning VBA but I still have very much to learn.
I have tried tweaking the code to:
Sub CostModelOutput()
Dim dvCell As Range, dvCell2 As Range, dvCell3 As Range, dvCell4 As Range
Dim inputRange As Range, inputRange2 As Range, inputRange3 As Range, inputRange4 As Range
Dim c As Range, d As Range, e As Range, f As Range
Dim i As Long, j As Long, k As Long, l As Long
Dim NumberRows As Long, NumberRows2 As Long
'Which cell has data validation
Set dvCell = Worksheets("Contacts").Range("J28")
Set dvCell2 = Worksheets("Contacts").Range("N28")
Set dvCell3 = Worksheets("Contacts").Range("N28")
Set dvCell4 = Worksheets("Contacts").Range("N28")
'Determine where validation comes from
Set inputRange = Evaluate(Range("J28").Validation.Formula1)
Set inputRange2 = Evaluate(Range("N28").Validation.Formula1)
Set inputRange3 = Evaluate(Range("R28").Validation.Formula1)
Set inputRange4 = Evaluate(Range("U28").Validation.Formula1)
i = 3
'Begin our loop
Application.ScreenUpdating = True
Sheets("Contacts").Activate
For Each c In inputRange
For Each d In inputRange2
For Each e In inputRange3
For Each f In inputRange4
dvCell = c.Value
dvCell2 = d.Value
dvCell3 = e.Value
dvCell4 = f.Value
'MsgBox dvCell
' MsgBox dvCell2
' MsgBox dvCell3
'MsgBox dvCell4
Debug.Print dvCell, dvCell2, dvCell3, dvCell4
Debug.Print dvCell, dvCell2, dvCell3, dvCell4
i = i + 1
Next e
j = j + 1
Next d
k = k + 1
Next f
l = l + 1
Next c
End Sub