Odd behaviour. I'm putting formulas into cells. I have created an array of strings that are formulas.
When I set a large range's .FormulaR1C1 property with that array, I see text in the cells (like "=R[-1]C18"). The right string goes in the right cell, but I want formulas not text. This happens even if the General Preferences is set to R1C1 style.
If I loop through the range, putting each element in the array in its cell, it reads them like formulas.
What's going on? Is there a reliable way that I can put formulas in cells in bulk fashion?
Dim xRay as Range, formulaRRay() as String, testSize as Long
ReDim formulaArray(1 To testSize)
For i = 1 To testSize
formulaArray(i) = "=R[-1]C" & CStr(xRay.Cells(i).Column)
Next i
Rem fills cells with text like "=R[-1]C12"
xRay.Offset(1, 0).FormulaR1C1 = formulaArray
Exit Sub
Rem fills cells with formulas
For i = 1 To testSize
xRay.Cells(2, i).FormulaR1C1 = formulaArray(i)
Next i
More oddness, I tried putting some dummy values in the routine above for this post. AND IT WORKS FINE. but the orgininal code still behaves as described.
Sub test()
Dim xRay As Range, formulaRRay() As String, testSize As Long, i As Long
Set xRay = Range("a1")
testSize = 12
Set xRay = xRay.Resize(1, testSize)
ReDim FormulaArray(1 To testSize)
For i = 1 To testSize
FormulaArray(i) = "=R[-1]C" & CStr(xRay.Cells(i).Column)
Next i
Rem fills cells with text like "=R[-1]C12"
xRay.Offset(1, 0).FormulaR1C1 = FormulaArray
Exit Sub
Rem fills cells with formulas
For i = 1 To testSize
xRay.Cells(2, i).FormulaR1C1 = FormulaArray(i)
Next i
End Sub
Excel 2004 for Mac.