My workbook looks like this:
Sheet1:
A B C D
1 VarName Multiplier1 Multiplier2 Multiplier3
2 Var1 0.3 0.8 0.4
3 Var2 0.4 0.9 0.1
...
100 Var100 0.2 0.2 0.7
101 Parameter1 Parameter2 Index
102 Sheet2!A2 Sheet2!B2 Complicated formulas like =SUMPRODUCT(B2:B100, C2:C100, D2:D100)+C102/B102
Sheet2:
A B C
1 Parameter1 Parameter2 FinalResult
2 100 25 Complicated formulas like =IF(Sheet1!D102<1, 1, Sheet1!D102)
Sheet3:
A B C
1 Parameter1 Parameter2 FinalResult
2 110 30 ?
3 140 40 ?
...(about 200,000 rows)
More informaton: In Both Sheet1 and Sheet2, the actual formulas are much more complicated than the ones shown here. In Sheet1 we have 154 intermediate variables calculated from 7 basic parameters from Sheet2, the sumproduct is just one intermediate function. In Sheet2 there are 15 different cases depending on parameters and index calculated from Sheet1. So basically I cannot hard code them together and the only entrance is in Sheet2. Another reason I wouldn't change Sheet1 and Sheet2 is because this is a model bought from other company and the way we are told to use it is to input parameters in Sheet2.
How can I write formula in Column C of Sheet3 so that I can calculate the result for every pair of Parameter1 and Parameter2? I tried recording macro to copy and paste like the following:
Sub ToEnd()
Dim i As Long
Application.ScreenUpdating = False
i = 1
While i < 200000
Worksheets("Sheet3").Range("A1:B1").Offset(i, 0).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Range("C2").Select
Selection.Copy
Sheets("Sheet3").Select
Range("C1").Offset(i, 0).Select
Selection.PasteSpecial Paste:=xlValues
i = i + 1
Wend
End Sub
But in 6 seconds I only get 200 results,I estimate the time complexity for one case to be 10^4 at most, so it is much slower than what I expected. I wonder if there's something can be written in C2 of Sheet3 looks like
=PassingParameterAndGetReturnValue(A2:B2, Sheet2!$A$2:$B$2, Sheet2!$C$2)
that I can autofill with inner loop hence faster? Or any other better way to do my task would be welcome.