Hi Ann,
Here are some hints about this function and how it works:
- 'Code' is the data field, which cannot be simply typed in. Make sure that you are inserting the Code field from the proper place, not just typing it.
- The Locate function simply searches an array (such as 'Code') for a particular value (such as "VAPE"), and if the value is found, the position of "VAPE" in the array is returned. That means if "VAPE" was the 6th element, then the value of the Locate function would be 6.
- 'YTD Amount' is also a field like 'Code' and needs to be inserted when creating the formula, not simply typed in. Inside the square brackets would be a single number, and the result would be the amount contained in the Nth element of the array.
You can see the logic of this formula. Locate is used to find "VAPE" in the Code array. If it finds it, then a number is returned indicating the position. That position is then used to find the appropriate YTD Amount. Of course, this construction breaks down if "VAPE" cannot be found in the Code.
To test this out, instead create a new formula that does not use YTD amount nor the square brackets:
Locate("VAPE",Code)
This should simply return a number from 1-32, or 0 if not found. If you get any zeroes, that would explain your errors you have found. Make sure that you have correctly typed "VAPE" and other codes so that the correct value is searched for.
Good luck!