J
Jaq23
I have a macro which generates formulae based on certain criteria.
This has seemed to work fine until now (although with a lot of these,
it's difficult to check) but I'm noticing an output that isn't
correct. The formula that has been generated is:
=MIN(1,(IF(ISNA(MATCH("PRP",$1:$1,0)),0,OFFSET(startFormula,ROW()-
ROW(startFormula),MATCH("PRP",$1:$1,0)-COLUMN(startFormula)))))
The column with "PRP" does exist, the value is empty (equating to a
FALSE or 0 value) for most rows. This should correspond to the values
in the PRP column by setting the result to 1 when the column shows
TRUE and 0 when the corresponding cell is blank.
By stepping into the formula, highlighting and calculating small
sections of the formula (using F9); it eventually drills down to
=MIN(1, {0}) = 0. But with the full formula, it's setting all outputs
to 1.
This is the most simple form of the formula, with the original
condition just stating "PRP" as opposed to some of the more
complicated criteria so if this isn't working, everything may be
wrong. Interestingly, the column to the left of this, with the formula
shown below, is producing values of 0.
=MIN(1,(IF(ISNA(MATCH("IMM",$1:$1,0)),0,OFFSET(startFormula,ROW()-
ROW(startFormula),MATCH("IMM",$1:$1,0)-
COLUMN(startFormula))))*NOT(IF(ISNA(MATCH("PRP",$1:$1,0)),
0,OFFSET(startFormula,ROW()-ROW(startFormula),MATCH("PRP",$1:$1,0)-
COLUMN(startFormula))))*NOT(IF(ISNA(MATCH("END",$1:$1,0)),
0,OFFSET(startFormula,ROW()-ROW(startFormula),MATCH("END",$1:$1,0)-
COLUMN(startFormula)))))
This has seemed to work fine until now (although with a lot of these,
it's difficult to check) but I'm noticing an output that isn't
correct. The formula that has been generated is:
=MIN(1,(IF(ISNA(MATCH("PRP",$1:$1,0)),0,OFFSET(startFormula,ROW()-
ROW(startFormula),MATCH("PRP",$1:$1,0)-COLUMN(startFormula)))))
The column with "PRP" does exist, the value is empty (equating to a
FALSE or 0 value) for most rows. This should correspond to the values
in the PRP column by setting the result to 1 when the column shows
TRUE and 0 when the corresponding cell is blank.
By stepping into the formula, highlighting and calculating small
sections of the formula (using F9); it eventually drills down to
=MIN(1, {0}) = 0. But with the full formula, it's setting all outputs
to 1.
This is the most simple form of the formula, with the original
condition just stating "PRP" as opposed to some of the more
complicated criteria so if this isn't working, everything may be
wrong. Interestingly, the column to the left of this, with the formula
shown below, is producing values of 0.
=MIN(1,(IF(ISNA(MATCH("IMM",$1:$1,0)),0,OFFSET(startFormula,ROW()-
ROW(startFormula),MATCH("IMM",$1:$1,0)-
COLUMN(startFormula))))*NOT(IF(ISNA(MATCH("PRP",$1:$1,0)),
0,OFFSET(startFormula,ROW()-ROW(startFormula),MATCH("PRP",$1:$1,0)-
COLUMN(startFormula))))*NOT(IF(ISNA(MATCH("END",$1:$1,0)),
0,OFFSET(startFormula,ROW()-ROW(startFormula),MATCH("END",$1:$1,0)-
COLUMN(startFormula)))))