Hello, i rather new vba and i have found great a difficulty to find a solution for this problem.
I have a flat xls table with 100000+ rows and 100+ columns with blank cells, 0 value cells, >0 value cells and <0 cells . What i want to do is a vba code to run through every line and when it finds a <0 value cell to go back and start subtracting this value from the previous cells until it comes to =0 OR >0 (subtract only from the positive ones). Then continue from were it stopped (the negative value) until the end of the line. Then it has to loop for every line until the end. Blank and 0 cells are considered as 0 value.Please see below an example of a test dataset and the desired results. The "tricky" part is in Line 3 where the subtraction leads to negative result since there are no more values to subtract and in this case sets the cell value to 0.
Thank you in advance
Abdul Raheem
I have a flat xls table with 100000+ rows and 100+ columns with blank cells, 0 value cells, >0 value cells and <0 cells . What i want to do is a vba code to run through every line and when it finds a <0 value cell to go back and start subtracting this value from the previous cells until it comes to =0 OR >0 (subtract only from the positive ones). Then continue from were it stopped (the negative value) until the end of the line. Then it has to loop for every line until the end. Blank and 0 cells are considered as 0 value.Please see below an example of a test dataset and the desired results. The "tricky" part is in Line 3 where the subtraction leads to negative result since there are no more values to subtract and in this case sets the cell value to 0.
Thank you in advance
Abdul Raheem
L1 | 100 | 50 | 0 | -10 | 100 | -50 | |||
L2 | 0 | 200 | -100 | -50 | 40 | -10 | 50 | ||
L3 | 300 | -400 | 100 | 50 | 30 | ||||
L4 | 100 | 100 | 100 | 100 | -450 | 100 | -50 | ||
L1_Result | 100 | 40 | 0 | 0 | 50 | 0 | |||
L2_Result | 0 | 50 | 0 | 0 | 30 | 0 | 50 | ||
L3_Result | 0 | 0 | 100 | 50 | 30 | ||||
L4_Result | 50 | 0 | 0 | 0 | 0 | 50 |