Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to calculate total Sum in Excel

I am producing last report for my venture. I need to ascertain the Sum of aggregate cells in my excel sheet. I have done the accompanying code. Be that as it may, its not computing the qualities.. Here is my code:

        Worksheet.Cells[20, 16].Formula =
                  "Sum(" + Worksheet.Cells[6, 16].Value + 
                 ":" + Worksheet.Cells[rowIndex, 16].Value + ")";

I need to figure the Cell No 16's Sum esteem and I will show it into Cells[20,16]. Its not working. Anybody help me to settle this?

like image 315
Raj De Inno Avatar asked Oct 13 '14 10:10

Raj De Inno


1 Answers

Change the two occurrences of .Value in your code to .Address.

Update ... and add a = before the Sum:

Worksheet.Cells[20, 16].Formula =
        "=Sum(" + Worksheet.Cells[6, 16].Address + 
        ":" + Worksheet.Cells[rowIndex, 16].Address + ")";
like image 50
Fratyx Avatar answered Sep 23 '22 04:09

Fratyx