December 8, 2016
I have debit and credit values in Col H. I am looking for VBA to delete all the rows where the values sum up to zero
I have highlighted the values that add up to zero using a blue font
I have showing the items not to be delete on a seperate sheet for ease of reference
Your assistance is most appreciated
I have also posted on https://www.excelforum.com/exc.....col-h.html
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
Hi Howard,
The values that will sum to 0 will always be consecutive? For example, code should start from row 2 and stop when moving sum plus next row is zero?
If you intend to combine rows in all possible ways to get a zero, that's hard.
By the way, the sum of the blue cells is 0.00000000000198951966012828, not 0.
December 8, 2016
Hi Catalin
Thanks for the reply.
One may have consecutive values balancing to zero for eg H2 could be 10000 and H3 -10000. You may also have situations where for e.g. H3 is 4000, h4 is 7500 and H15 is -11500 , then these rows must be deleted
the only items left should be those that do not sum to zero rounded to 2 decimal places
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
Have you tried this formula?
https://www.myonlinetraininghu.....on-formula
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
However, that formula works for same debit-credit amounts.
Without a unique identifier that ties the credit transactions to that specific debit transactions, it’s almost impossible, you have to dig through all transactions, combine the credit values until one debit transaction matches. And that is most likely a source of errors, as we don't know if a debit transaction has 1 or 100 credit amounts.
Let's take 1 case:
5 debit amounts: 1 of 1000 and 4 of 250. Total debits: 2000.
We might have these credit amounts, totaling 2000:
1:250,
2:300,
3:200,
4:250,
5:250,
6:500,
7:250
As there is no rule that limits the number of credit amounts, the 1000 debit can be matched by adding 1,4,5,7, or 2,3,6, or 1,2,3,4, or more combinations.
The only way to match all 5 debits is to match 1000 with 2,3,6 and the other 4 debits with 1,4,5 and 7, but code cannot decide which combination is best.
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
What's the difference?
Still needs to combine 1 to many credits to identify a debit.
The only notable difference is that now your Data Ref column is NOT empty, but there are some inconsistencies:
Data Ref 14396 has 2 credits, combined credits matches the 1081.46 debit.
But: there are 2 credits with 288872-data ref, where each credit is matching 2 separate debits. This inconsistency makes Data Ref unusable.
To be of any use, as you have been told, you need to have identifiers. Data Ref might be usable but only if there are no inconsistencies like the one mentioned above.
Where do you get data from?
Can we see an original data set?
Why Data Ref is empty in one of your example files?
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
December 8, 2016
Thanks for all your input
Going forward going to get my staff to process one credit for every debit and vice versa and to use the same reference number where transaction is the same for eg Ref 123 for 1000 and 123 for -1000
This will make it easier to program
Regards
Howard
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
December 8, 2016
Hi Catalin
It would be appreciated if you write code that where the Narrative in Col I contains similar text within the narrative for e.g. "fuel" then to match the debits and credits for that category and if those items pertaining to those add up to zero and the text contains a common item for eg fuel ,then to delete those rows ,
The data is processed in different companies so the reference numbers will seldom be the same as it relates to intercompany transactions so the only other alternative is for the staff to have similar text in the narrative
I have highlighted the items where the debits and credits match and the narrative containing a common item in the text
1 Guest(s)