I am trying to do something that I thought would be easy (and I've simplified it!)
I have a list of numbers in Column1 of a worksheet.
I want to specify USING VBA that the formula in cell(4,4) of that sheet should be a SUM of all the cells in column1.
If I manually select a cell in Sheet1 I can type in it:
=SUM(C1)
This works fine, and I get the result as expected.
However my one line macro doesn't work:
Worksheets(1).Cells(4, 4).Formula = "=SUM(C1)"
For some reason when VBA puts this into the Excel cell, Excel decides that actually it would prefer the formula to be:
=SUM(R[-3]C[-1])
Which of course gives the wrong result.
Does anyone know why this is happening?
I've attached an example to illustrate the problem.
In Cell(5,4) i have manually typed in "=SUM(C1)", and cell(4,4) is where the VBA code trys to put in the identical formula.
Many thanks!
Bookmarks