ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help with a simple macro, really lost. (https://www.excelbanter.com/excel-programming/445349-need-help-simple-macro-really-lost.html)

Mike L.[_3_]

Need help with a simple macro, really lost.
 
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

Tim Williams[_4_]

Need help with a simple macro, really lost.
 
Are the inputs on the same sheet as the outputs, or on a different
sheet ?

dim i,x

for 1=1 to 100






Tim

On Feb 8, 2:30*pm, "Mike L." wrote:
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



Tim Williams[_4_]

Need help with a simple macro, really lost.
 
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



On Feb 8, 2:30*pm, "Mike L." wrote:
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




All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com