
Here I am once again, asking for help on this great community.
I hope I can retribute as much as you did someday.
The 4th column (D) in the picture is the expected output.
This is how I put the problem:
-
If a number is negative / or has an A (number in the A row is always negative);
-
Use MATCH to check if there is a correspondent (positive) number in the range (between headers);
-
If there is a MATCH output the value of the ID (1st column) of the F that has been matched, and then, output the ID of the A that has been matched
-
-
If not, do nothing or place a 0.
The problems are:
-
It needs to loop, because the negative value can come after the positive one;
-
The search must be contained between headers.
I’ve tried to modify and create my own solutions from the tips and codes of the other questions I’ve placed, but with no success..
Thank you so much!
Try pasting this into the immediate window of the VBE and hitting enter:
The output for the example data in the question is:
Note: This method uses named arrays to store intermediate results for header positions
hand section lengthsland takes around 3-4 secs when the range namesi(id),v(value) andm(match) are extended to 40,000 rows. A simpler formula for this is possible but it would be very inefficient to fill down on large data sets.