But that way I get rows which belong to other accounts. So Is there a smart way to manipulate this input to remove all rows which belong to an account with a positive total instead of removing singular rows.
Desired output would be:
I’m not sure whether there’s an elegant solution to this, other than looping through and manipulating the data table.
One way I can think of - which is not elegant but will work - is the following:
Read the Excel sheet as a DataTable
Add a new column to the DataTable
For each row, update the new column to match the corresponding Account Number
Find all lines where the Account Number is not empty (basically just the yellow lines) and where the total is negative → From these lines, extract the Account Number
Delete all lines matching the Account Number you’ve found (this is now doable because each line will hold the Account Number it refers to)