i have a vba line of code like this:
ActiveCell.FormulaR1C1 = "=LOOKUP(""ETG_C"",RC[-10],RC[-8])"
i would like to know how is it possible to have the activecell formula be something else in the case that it does not find ETG_C
for example:
=if(not(LOOKUP(""ETG_C"",RC[-10],RC[-8]))开发者_如何学Python) then =LOOKUP(""something_else"",RC[-10],RC[-8])
Yes it is possible.
The key is to check first formula for errors with ISERROR(value) formula
this goes like this:
=IF(ISERROR(FIRST_STATEMENT),SECOND_STATEMENT,FIRST_STATEMENT)
so in your case it should be like:
=if(iserror(LOOKUP(""ETG_C"",RC[-10],RC[-8])), LOOKUP(""something_else"",RC[-10],RC[-8]), LOOKUP(""ETG_C"",RC[-10],RC[-8]))
精彩评论