Hello @udouyolo ,
This is one way: You have to perform a few DataTable based operations after reading the worksheets in.
Then there may be fixed conventions that you might have to adopt.
For Sheet 2:
- In Sheet 2 (lower in your picture), I would make the following fixed assumptions:
- The Read begins from A4 and not A1. So my read range input would be A4 and not A1
- If you read this range into DataTable2 then all your totals are on the last Row which corresponds to:
DataTable2.Rows.Count or DataTable2.Rows.Count-1
based on whether or not you are enabling AddHeader option when Reading the worksheet.
rowNum = 4+DataTable.Rows.Count or 4+DataTable.Rows.Count-1
Again, depending on the header, and 4 is the starting row of Sheet 2
Therefore the start range of the Totals Row you have to Read is
"B"+rowNum.ToString() through "M"+rowNum.ToString()
Obviously “N” in this case is again variable, but over a year there are only 12 months so an additional logic can help you figure that out based on the current month. Starting from Column B4 you will read on 12 columns regardless of the what the start and end months are on this Sheet
For Sheet 1:
I presume that the Totals column is fixed in which case you would read this row into another DataTable. The start range for this would be A6.
Now that you have both DataTables in memory, each containing one row all totals. You can do a DataTable compare on the Totals to arrive at your decision logic. By this time you know what the Rows and cells you are comparing.
Example in this case it's Row 6 on Sheet1 and Row 25, Cells B25 through M25 (per the math above) on Sheet 2.
You must be able to use that in the Highlight Cell activity to mark that cell if any of the totals don’t match
I hope this helps.