Sum cells in excel in a specific line

Hello everyone
I need to add the coloured line into my excel file. (H11 = sum from H6 to H10 and it is the same method to all the other coloured cells.) the row index is dynamic


  1. If the row index is dynamic first to find the rows…read the data into datatable and check where the required value is present in the column A…in a merged cell when read into datatable…the data will always be present only in the first cell…so effectively using for loop and if condition on xxx715 currentrow(0).Tostring.equals("xxx715"), use a counter to find the row index of that…

Now you have the start index …similarly after that find the last row by using if condition on column H when it would be blank…

Use both of them and send formula using write cell… "=Sum(H" + startindex.ToString + ":H" + endindex.ToString + ")"

Hope this helps


Should i use : add data row if i find the xxxx7715 in the data table?


No add data row is needed…you are only trying to find the start and end indexes and then use it to perform your sum… if found you need to save the index of the row…Index cna be obtained from the properties of for loop


The row where i have the sum is not already in the excel.
What i shared is the output that we want to get. So i need to add the row before doing the sum

Hi @dhouha.cherif ,

Could you let us know what is your Input Data representation before performing this addition of Sum row ?
If you could provide us a Screenshot of it, it would be helpful.

The first input is


So then search for *722 before that and add a row and then perform the remaining steps

Else can you please share


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.