I am using an array formula (in Excel 2003) to count the number of strings meeting a specific condition. I am using a column of strings instead of a table of cells to store my data because of file size limitations.
The formula is below:
{=SUM(IF((VALUE(MID(INDIRECT(CONCATENATE(D1,"test")),6,1))*VALUE(MID(INDIRECT(CONCATENATE(D1,"test")),1,1)))=VLOOKUP(D2,t.lkup,2,FALSE),1,0))}
The expression VALUE(MID(INDIRECT(CONCATENATE(D1,"test")),6,1))
looks through the cells in a named range to return a value. This value is multiplied by another value returned by the expression VALUE(MID(INDIRECT(CONCATENATE(D1,"test")),1,1))
. The resulting product is then looked for in a set of numbers given by VLOOKUP(D2,t.lkup,2,FALSE)
, which returns a string like "{1,2,3,4}". If the product is an element of set, then 1 is added to the sum, else 0 is added to the sum.
When I use the array formula above (with the dynamic lookup set), a value of zero is returned. If I use the following formula,
{=SUM(IF((VALUE(MID(INDIRECT(CONCATENATE(D1,"test")),6,1))*VALUE(MID(INDIRECT(CONCATENATE(D1,"test")),1,1)))={1,2,3,4},1,0))}
then the correct sum is returned. Does anyone know how to get Excel to treat the set lookup as a static set instead of a string?