Sounds like you need to build a table and use a lookup function.

See if this helps:

http://contextures.com/xlFunctions02.html