excelliststaticformulahardcoded

is it possible to use a hardcoded list of values instead of a range in range-formulas?


I was wondering if I could hardcode an array or "range" into a formula. So, for example, if I wanted to see if a month in B2 is March, April, June or July, I would like to compress this this:

=COUNTIF(a1:a4,MONTH(B2))>0

where A1:a4 = 3,4,6,7

to simply:

=COUNTIF((3,4,6,7),MONTH(B2))>0

so that I do not need extraneous lists in other cells


Solution

  • Yes you can, just use "{ }" rather than "( )" to surround your list of values.

    =COUNTIF({3,4,6,7},MONTH(B2))>0
    

    I didn't test if your logic worked but showed where to put the braces.