In this thread https://www.ozgrid.com/forum/forum/...p-down-list-and-copy-paste-the-value?t=190022 I found the following code. I have cross-posted this at https://www.ozgrid.com/forum/forum/...ooping-through-multiple-data-validation-lists
How can I incorporate the second for each loop in the first loop? I want the for each loops to step every step in the data validation cells and count the number of X and Y.
Code:
Option Explicit
Sub CostModelOutput()
Dim dvCell As Range, dvCell2 As Range
Dim inputRange As Range, inputRange2 As Range
Dim c As Range, d As Range
Dim i As Long, j As Long
Dim NumberRows As Long, NumberRows2 As Long
'Which cell has data validation
Set dvCell = Worksheets("Input").Range("J28")
Set dvCell2 = Worksheets("Input").Range("N28")
'Determine where validation comes from
Set inputRange = Evaluate(Range("J28").Validation.Formula1)
Set inputRange2 = Evaluate(Range("N28").Validation.Formula1)
i = 3
'Begin our loop
Application.ScreenUpdating = True
Sheets("Input").Activate
For Each c In inputRange
dvCell = c.Value
MsgBox dvCell
NumberRows = Application.WorksheetFunction.CountA(Columns("A:U"))
Range("X2").Value = NumberRows
Worksheets("Output").Cells(i, "B").Value = Worksheets("Input").Range("C4").Value
Debug.Print dvCell
i = i + 1
Next c
Sheets("Input").Activate
j = 3
For Each d In inputRange2
dvCell2 = d.Value
MsgBox dvCell2
NumberRows2 = Application.WorksheetFunction.CountA(Columns("A:U"))
Range("y2").Value = NumberRows2
Worksheets("Output").Cells(i, "B").Value = Worksheets("Input").Range("C4").Value
'Worksheets("Output").Cells(i, "B").Value = Worksheets("Input").Range("C4").Value
'Worksheets("Output").Cells(i, "C").Value = Worksheets("Input").Range("C5").Value
'Worksheets("Output").Cells(i, "E").Value = Worksheets("Input").Range("C1").Value
'Worksheets("Output").Cells(i, "F").Value = Worksheets("Input").Range("H1").Value
j = j + 1
Next d
Application.ScreenUpdating = True
End Sub
How can I incorporate the second for each loop in the first loop? I want the for each loops to step every step in the data validation cells and count the number of X and Y.