I have an app that creates excel workbooks, filling with data, graphs etc no problem.

I now want to create a formula on Sheet2 that references a cell on Sheet1.

I can do it no problem with the following line of code

worksheet.get_Range(worksheet.Cells[curRowIx, curColIx], worksheet.Cells[curRowIx, curColIx]).Formula = "='SN21'!C" + **startRow**;

using the **startRow ** in the formula i can loop through the rows no problem and it works. What i need is to be able to access the column in a loop also. Not using C1 but R[x]C[y] so i can loop through all data i need and populate the formulas correctly.

I know i can hardcode all the A1, B1 ... etc but that makes me nauseous and i hate repetitive code. I want to use something like

.Formula = "='SN21'" + worksheet.Cells[curRowIx, curColIx] but i cant get it to work

Thanks in advance

...FormulaR1C1 = "='SN21'!R3C3"

you can work with R3C3 (row 3 column 3) instead of C3 (the cell address...)

when you use absolute numbers like that, you're meaning the exact cell address.

when you use like:

...FormulaR1C1 = "='SN21'!R[3]C[-1]"

(with these square brackets) it means relative reference to the cell you're putting the formula in...

[3] is a positive number, would mean 3 rows down

[-1] is a negative number, would mean 1 column to the left

see, since the whole formula would be a string, you can treat it as you want...

Even change the 21 to 22 or whatever...