I'm embarassed to say that after the umpteenth time of looking through
this code and thinking about it, the solution jumped out at me.
Amending the code to read:
bMFE = IIf(TT = 2, TT, IIf(TT > 2 And MFE <= CumGn, TT, bMFE))
fixed it. The complete sequence is shown below.
MFE = IIf(TT = 2, CumGn, IIf(TT > 2 And MFE < CumGn, CumGn, MFE))
bMFE = IIf(TT = 2, TT, IIf(TT > 2 And MFE <= CumGn, TT, bMFE))
MFE and CumGn are double precision calculated values that are compared
and the higher chosen (first line). Then, an identifying number, or
the "bar" number (which actually is the TT)of the winner is chosen in
the second line, and that becomes the new bMFE, an integer. There is
no MFE or CumGn at TT = 1, or bar 1; at bar 2 the CumGn is calculated
and it also becomes the first MFE. From bar 3 on the new CumGn is
calculated and then compared to the MFE from the step before it, etc.
The MFE increases only when the CumGn increases; it never decreases,
and the bar number, the bMFE, will then change. I had overlooked the
instance when the CumGn and MFE are the same.