Need help with a simple macro, really lost.

  • Thread starter Thread starter Mike L.
  • Start date Start date
M

Mike L.

I have two inputs
C2 and G2

that go through a complex blue printing system to generate a bunch of
values, call them

'sheet2'!a4
'sheet2'!b6

and a bunch more.

I want to write a macro that will get the outputs from a4 and b6 for
a range of 1 to 100 for c2 and 1 to 100 for g2 and display it on two
columns

C2 | G2 | output from a4 | output from b6 |
1 1 ouput1 output1
1 2 output2 output2
....
100 100 output9999 output9999
 
Are the inputs on the same sheet as the outputs, or on a different
sheet ?

dim i,x

for 1=1 to 100






Tim
 
Not clear if your inputs are on the same sheet as the outputs: this
assumes a different sheet....

Sub GetValues()

Dim a, b
Dim rngResult As Range
Dim shtOutput As Worksheet, shtInput As Worksheet

Set shtInput = ThisWorkbook.Sheets("Sheet1")
Set shtOutput = ThisWorkbook.Sheets("Sheet2")
Set rngResult = ThisWorkbook.Sheets("Results").Rows(2)

For a = 1 To 100
For b = 1 To 100

shtInput.Range("C2").Value = a
shtInput.Range("G2").Value = b
Application.Calculate
DoEvents

With rngResult
.Cells(1).Value = a
.Cells(2).Value = b
.Cells(3).Value = shtOutput.Range("A4").Value
.Cells(4).Value = shtOutput.Range("B6").Value
End With

Set rngResult = rngResult.Offset(1, 0)
Next b
Next a

End Sub
 
Back
Top