Hi Folks,
Below subroutine seems to create the desired formula okay. However, when formula is written to target cell apostrophies seem to have been inserted, making the formula non-functional.
Desired formula is: =Sum(F1:F5)
Inserted formula is: =Sum('F1':'F5')
How do I build VB code such that apostrophies won't be inserted?
Thanks!
Randy
Sub WriteFormula()
Dim BottomCellAddress
Dim TopCellAddress
Dim SumField
TopCellAddress = Cells(1, 6).Value
BottomCellAddress = Cells(5, 6).Value
SumField = "=Sum(F" & TopCellAddress & ":F" & BottomCellAddress & ")" 'Yields: =Sum(F1:F5)
Range("G1").Select
ActiveCell.FormulaR1C1 = SumField
End Sub
Below subroutine seems to create the desired formula okay. However, when formula is written to target cell apostrophies seem to have been inserted, making the formula non-functional.
Desired formula is: =Sum(F1:F5)
Inserted formula is: =Sum('F1':'F5')
How do I build VB code such that apostrophies won't be inserted?
Thanks!
Randy
Sub WriteFormula()
Dim BottomCellAddress
Dim TopCellAddress
Dim SumField
TopCellAddress = Cells(1, 6).Value
BottomCellAddress = Cells(5, 6).Value
SumField = "=Sum(F" & TopCellAddress & ":F" & BottomCellAddress & ")" 'Yields: =Sum(F1:F5)
Range("G1").Select
ActiveCell.FormulaR1C1 = SumField
End Sub