S
smokiesandwine
Storing formula's in an array, calculating SUM in the array then
returning result into a cell without formula. this basically does the
calculation however the formula is in the cell
so far i have .......
Sub FormulaTest()
Dim myFormula(0 To 5) As String
Dim myresult(0 To 5) As String
Dim myFlag As Boolean
Dim x As Integer
Dim i As Integer
Dim Result As String
Dim qwerty As Variant
'Select cells A10 to A15
Range("A10:A15") = ""
'Fill the array with formulas
myFormula(0) = "=SUM(10+12)"
myFormula(1) = "=SUM(20+12)"
myFormula(2) = "=SUM(30+12)"
myFormula(3) = "=SUM(40+12)"
myFormula(4) = "=SUM(50+12)"
myFormula(5) = "=SUM(60+12)"
Do Until myFlag = True
For i = 0 To 5
'NEED SOME CODE IN HERE } need to keep the result of the
formula and put it in the next cell
' ActiveCell = myFormula(i) } this will enter the
formula along with the result in the cell
ActiveCell.Offset(1, 0).Select } moves to the next cell
down
If i = 5 Then
myFlag = True: Exit For
End If
Next i
Loop
End Sub
returning result into a cell without formula. this basically does the
calculation however the formula is in the cell
so far i have .......
Sub FormulaTest()
Dim myFormula(0 To 5) As String
Dim myresult(0 To 5) As String
Dim myFlag As Boolean
Dim x As Integer
Dim i As Integer
Dim Result As String
Dim qwerty As Variant
'Select cells A10 to A15
Range("A10:A15") = ""
'Fill the array with formulas
myFormula(0) = "=SUM(10+12)"
myFormula(1) = "=SUM(20+12)"
myFormula(2) = "=SUM(30+12)"
myFormula(3) = "=SUM(40+12)"
myFormula(4) = "=SUM(50+12)"
myFormula(5) = "=SUM(60+12)"
Do Until myFlag = True
For i = 0 To 5
'NEED SOME CODE IN HERE } need to keep the result of the
formula and put it in the next cell
' ActiveCell = myFormula(i) } this will enter the
formula along with the result in the cell
ActiveCell.Offset(1, 0).Select } moves to the next cell
down
If i = 5 Then
myFlag = True: Exit For
End If
Next i
Loop
End Sub