Formula advice on how to return value based on specific text within string

vegas86
vegas86 used Ask the Experts™
on
Hello,

Can someone please help me? I have attached an example of what I am working on.
I need my formula to look for specific text and then return a number based on that text. You will see that in A2 I have =IF(ISNUMBER(SEARCH("Weekdays SchHols",A5)),"62") and in B2 I have =IF(ISNUMBER(SEARCH("weekdays",A5)),"42") but these two formulas are working off one value- A5. What I want to be getting is the value of 62 because that’s what I have specified for Weekdays SchHols but it is picking up Weekdays on its own as well. Is there a way to narrow it down to only provide me with the one value.
In saying this though I need my formula to include all 5 names written in column I with the corresponding value in column J, so if it has Sunday in the range it will return 14, if Saturdays was in the range it would instead return 12.

Can someone please help me out and let me know how I would go about solving this?

example.xlsx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2008

Commented:
You will probably need to make the formulas more dependent on each other.

See attached.

Kevin
Q-26946372.xlsx

Author

Commented:
Hi Zorvek,

Thanks for your suggestion it works well but unfortunately I can’t do that in this situation, I only included two formulas as an example. My real sheet only has one formula and within that formula I need it to include all 5 ranges so that when a selection is made from a data validation list in column A the formula will automatically return the correct number value in column B.

Thanks though!
Top Expert 2008
Commented:
Use this single formula then:

=IF(ISNUMBER(SEARCH("Weekdays SchHols",A5)),"62",IF(ISNUMBER(SEARCH("Weekdays",A5)),"42",IF(ISNUMBER(SEARCH("Sundays",A5)),"14",IF(ISNUMBER(SEARCH("Saturdays",A5)),"12",IF(ISNUMBER(SEARCH("Weekday Holidays",A5)),"62",0)))))

Kevin

Author

Commented:
Just tried it then and it's fantastic, thanks for your help and time Kevin!! I appreciate it!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial