I am trying to create a nested loop to input the values in Range("E2:E6") into Cell ("B3") & values in range ("F2:F6") in cell ("B2"). And then record the results from Range("I2:j2") to Sheet2.
This answer (Excel VBA: How to create loop and save output for each value in range?) was a great help in first tackling the problem but I have become stuck as how how I may paste the 25 (5*5) possible resulting values of Range("I2:j2") to Sheet2
Any help much appreciated!
Sub Nested_Loop()
'
'
'
gg = 1
Dim myRange As Range
Dim myRange2 As Range
Dim i As Long, j As Long, h As Long
Worksheets("Sheet1").Activate
Set myRange = Range("E2:E6")
Set myRange2 = Range("F2:F6")
For h = 1 To myRange2.Rows.Count
For i = 1 To myRange.Rows.Count
For j = 1 To myRange.Columns.Count
myRange.Cells(i, j).Select
Selection.Copy
Range("B3").Select
ActiveSheet.Paste
myRange2.Cells(h, j).Select
Selection.Copy
Range("B2").Select
ActiveSheet.Paste
Range("I2:j2").Select
Application.CutCopyMode = False
Selection.Copy
Worksheets("Sheet2").Activate
Worksheets("Sheet2").Cells(i + 1, j + gg).Select 'I want to paste all 25 values (5 possible inputs for each variable(2)). Currently the loop only prints 5 results and then pastes over itself
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next j
Worksheets("Sheet1").Activate
Next i
Worksheets("Sheet1").Activate
Next h
End Sub