To Array, Or Not To Array?

SuperFerret

Well-known Member
Joined
Mar 2, 2009
Messages
515
I have a spreadsheet that is used every day, and it contains this formula:
Code:
=IF(A1="Pink",4,IF(A1="Black",5,IF(A1="Green",3,IF(A1="Blue",1,IF(A1="Yellow",7,8)))))

All this does is look at what word is chosen from a dropdown in a specified cell (for arguments sake A1) and returns a numeric value based on that

Pink - 4
Black - 5
Green - 3
Blue - 1
Yellow - 7
Otherwise default to 8

I've been trying to use array(?) but I haven't got a clue what I'm doing or whether this would actually be any quicker?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I'd use a lookup table rather than hardcoding an array in the formula.
 
Upvote 0
Thanks for the reply Rory. Normally I would use a lookup table, but the values are never going to change.

The formula I provided has been in use on the spreadsheet for years and hasn't needed amending, we're just trying to tweak it now for efficiency :-)
 
Upvote 0
I tried this (swiped from another thread) but it fails on Black, Blue and Blank :-(
Code:
=LOOKUP(A1,{"Pink","Black","Green","Blue","Yellow",""},{4,5,3,1,7,8})

Do I need to add EXACT or something in there?

Blank I can solve by making sure White is selected instead but Blue/Black?
 
Upvote 0
Ah... so more like this:
Code:
=LOOKUP(A1,{"Black","Blue","Green","Pink","White","Yellow"},{5,1,3,4,8,7})

But I'm still getting issues with Black and Blue?

Thanks Andrew I think I may be starting to get my head around this ;)
 
Upvote 0
Dave,

I can't get this to work when there is no value in A1, but try:
Code:
=LOOKUP(A1,{"Black","Blue","Green","Pink","White","Yellow","";4,5,3,1,7,8,9})

Your wife
 
Upvote 0
Wife,

Like my toilet, you have fixed the block in my knowledge. Any luck on those pegs?

Dave

Code:
=LOOKUP(A1,{"Black","Blue","Green","Pink","White","Yellow","";5,1,3,4,8,7,8})
 
Last edited:
Upvote 0
No, there's been some revolt in the country and my suppliers say production's been put on hold. Like your toilet, I have fixed your plumbing!
 
Upvote 0
Darn! I need my pegs! I hope they get it sorted soon, I'm having to train bluetits to perch on my washing line to keep stuff on it at the moment :-(
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top