2 inputs, v and q, have a range of values determined by the set min, max and increment values in a worksheet. D and Fs are lists of inputs stated in columns (Fs is dependent upon D).
I wish to bring in v and q incrementally, and also bring in D and FS in the order stated in the list.
I.e if there were 3 and 5 values of v and q respectively, and 3 values of each D and Fs, there should be 45 outputs.
Function valzArrayExp1(lMin As Double, lMax As Double, lInc As Double) As Variant
Dim i As Long
Dim TempArr As Variant
ReDim TempArr(0 To (lMax - lMin) / lInc)
For i = 0 To UBound(TempArr)
TempArr(i) = lMin + lInc * i
Next
valzArrayExp1 = TempArr
End Function
Sub Test()
Dim vValz, qValz, answers, v, q, inarr, d, Fs
Dim k As Double
Dim A As Double
With Worksheets(1)
A = .Range("C6")
vValz = valzArrayExp1(.Range("F5"), .Range("F4"), .Range("F6"))
qValz = valzArrayExp1(.Range("F17"), .Range("F16"), .Range("F18"))
End With
lastrow = Cells(Rows.Count, "P").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 16))
For i = 4 To lastrow
d = inarr(i, 11)
Fs = inarr(i, 39)
ReDim answers(1 To (UBound(vValz) + 1) * (UBound(qValz) + 1) * UBound(inarr), 1 To 1)
For Each d In inarr
For Each v In vValz
For Each q In qValz
k = k + 1
If d <> 0 Then answers(k, 1) = (v * A) / (d * q)
Next d, v, q, Fs
Range("AE4").Resize(UBound(answers, 1)) = answers
End Sub
Bookmarks