First, get a non macro solution working.
Second, post some example data please that illustrates your issue.
It's sometimes hard to follow the logic in words, and sometimes the correct terms aren't used but having the data makes that easier to determine.
You should be able to use IF first.C directly as far as I can tell, so not sure what B has to do with it, but an example will clarify that.
If you're uncertain you can also review the examples in the BY group processing in the documentation.
... View more