I have an excel sheet that maintains a cost amount for each day. Each day is posted on a new row. I would like to produce the calculation with the difference between the last row (newest amount) and the previous row and write the difference in a new column in the last row. I’m familiar with index and using the for each row, I’m just not sure how to get the previous row data and calculate it with the last row.
If the cost Amount value varies every time, then you have to take the reference first corresponding to the values find which cell exactly where the cost amount value is, suppose you found its “F” and its Cost amount is the last row, then use (datatable.rows.count-1) will give the last index and (datatable.rows.count-2) will give previous index of that.
Datatable.rows(datatable.rows.count-1).item(in which column the value is present) - Datatable.rows(datatable.rows.count-2).item(in which column the value is present)