I have one cell in a worksheet that has a relative formula (eg F23 =sum(F15:F22) - I want to copy it to the whole row but have it refer to the correct column (eg in cell A23 the formula should be =sum(A15:A22))

In native excel it’s simply a matter of copy and paste.

I’ve tried setting the cell’s formula property - but that makes all cells refer to the same column.

I’ve also tried the .Copy method but that has the same effect.

I searched the help file for “relative”, “fill”, “cell copy” with no success.

Am I missing something obvious?

Thanks!

Brad

Hi Brad,

Please try this attached version.

Workbook workbook = new Workbook();

workbook.Open("d:\\test\\book1.xls");

workbook.Worksheets[0].Cells["A23"].Copy(workbook.Worksheets[0].Cells["F23"]);

workbook.Save("d:\\test\\abc.xls");

Looks like your change fixes the relative reference issue -

at least for one case.

when the formula is like this =sum(f10:f23) it works

when the formula is like this =B11-B12-B13 it does not

I tested this by changing the formula form B11-B12-B13 to sum(B11:B13)

it adjusts correctly.

Strange.

Brad

Please try this attached fix.

That fix seems to have worked for all my formulae

thanks! - my app is almost 100% working now.

Brad