I am trying to make a table on one sheet that pulls cell values from other sheets depending on a indictor value in cell "C15". I am thinking I can continue doing "if" statements for each of the twelve indicators but first I need to correct what I have for the first indicator value. I have tried a few things but using the "...Formula="=vlookup..." seems to have been the easiest.
The issue comes with looping inside the formulas. It should start by looking up the value of "L6" on a certain sheet determined by the indicator. In this case, it's doing vlookup for three values from "H20_brine density", copying them to the active sheet, doing some math to get value "M6", and then it should repeat using "L7" (which is equal to "M6") until the rows have been completed. The "rows" are determined by another indicator and works fine.
Range("L6").Value = Range("C12")
If Range("C15").Value = 1 Then
For i = 6 To rows + 6
With autostatic
.Range("N" & i).Formula = "=vlookup(Li,'H2O_brine density tables'!AA$5:AG$80,5,TRUE)"
.Range("O" & i).Formula = "=vlookup(Li,'H2O_brine density tables'!AA$5:AG$80,6,TRUE)"
.Range("P" & i).Formula = "=vlookup(Li,'H2O_brine density tables'!AA$5:AG$80,7,TRUE)"
.Range("k" & i).Formula = "=Ji*Ni^2+Ji*Oi+Pi"
.Range("M" & i).Formula = "=Li+Ki*C13"
.Range("L" & i + 1).Formula = "=Mi"
End With
Next
End If