This project has moved. For the latest updates, please go here.

Possible to copy relative formulas when copying a cell range?

Sep 1, 2011 at 4:18 AM

I have a chunk of code that I am using to copy a range of cells from one location to another:

templateWorksheet.Cells["A" + templateRow + ":X" + (templateRow + 4)].Copy(new ExcelRangeBase(templateWorksheet, "A" + (templateRow + 4) + ":X" + (templateRow + 8)));

My issue is that when these cells copy they copy the absolute formula rather than the relative one.  For example if I have a row that has the formula

=A1+E1
And I copy that to the next line it does not change to:
=A2+E2
If I open the excel spread sheet and do the copy manually the rows adjust as they should.  Is there anyway to have formulas copy this way?

Editor
Sep 1, 2011 at 12:05 PM

No, you need to do programmatically. After copy yours cell, you need to recaculate theirs formula.