richard smith

richard smith

  • 1.3k
  • 285
  • 157k

Help with C# Excel SUM Function

Mar 20 2013 3:25 PM
I am using C#, and I want to run a sum formula until the last row with data....so what I was thinking was run something like this:
while (column H has data skipping row 1).Value != ""
{
_Workbook workbooksExcel = docExcel.ActiveWorkbook;
Worksheet sheetExcel = docExcel.ActiveSheet;
((Range)sheetExcel.Cells["2", E].Value2 = "=sum(E2,G2,I2)"
}

Of course that is a rough pseudocode of what I am wanting.  Essentially trying to where column H has data, in column E sum E2+G2+I2, then if column H still has data, then E3+G3+I3and carry on this same way until column H no longer has data in it.