问题
I have a list DataValidation formula with depends on other column.
OFFSET(DATA!A2;0;MATCH(A1;DATA!1:1;0)-1;COUNTA(OFFSET(DATA!A:A;0;MATCH(A1;DATA!1:1;0)-1))-1)
When other column is empty the formula evaluates to an error (MATCH results in #N/A
) and excel warns about it with:
"The source currently evaluates to an error. Do you want to continue?"
When I accept the warning popup DataValidation
results in empty list, which is fine for me.
My goal is to create formula which will never evaluate to error but provide default value instead.
Is there a way to handle such error and provide empty list for excel? Or list with one item containing empty string?
My current idea is to create handling error with providing default empty list. But I cannot create proper syntax for it.
IFERROR(myformula, <empty list or list with one empty string>)
Any help would be appreciated.
NOTE: this question originates from my other problem where I created python script to reproduce this case.
回答1:
Knowing MATCH results in #N/A
I wrapped it in IF(IFNA(...
IF(IFNA(failingformula;FALSE);formula;someCellWithEmptyValue)
and whole formula is
IF(IFNA(MATCH(A1;DATA!1:1;0);FALSE);OFFSET(DATA!A2;0;MATCH(A1;DATA!1:1;0)-1;COUNTA(OFFSET(DATA!A:A;0;MATCH(A1;DATA!1:1;0)-1))-1);C3)
where fomula
is written in question and C3
is some random cell I know will contain empty value.
Still if someone knows better and cleaner approach then please share the idea.
来源:https://stackoverflow.com/questions/59981861/handle-error-in-list-datavalidation-formula