Sum of rows from 2 DataTables

Hello! Please help me. I have 2 Excel spreadsheets. Both tables have a column named 6. I need to calculate the sum of each row of column 6 of table 1 with rows from column 6 of table 2. (for example: row 1 of table 1 + row 1 of table 2 and so on). I can’t calculate this amount. Then you need to perform a number of other calculations and save it all in a third Excel file. I attached the process, please see what my error is.

File1.xlsx (10.9 KB) File2.xlsx (10.8 KB) Последовательность1.xaml (16.8 KB)

Let me see if I understand what you want…
You want the numbers from the G column (your number 6) to be added together from Both Excel Files and written into the third Excel File?

If so, you overcomplicated the first for each.

I think it should be:

And the text in the assign method is:
CDbl(row.Item(6).ToString) + CDbl(DT2.Rows(dt1.Rows.IndexOf(row)).Item(6))

This now assigns the new value (From File 1 and file 2) to the dt1 that you later use to write in the third file.


1 Like

Thank you very much for your help!

1 Like

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