Excel Formula or Macro?

Lynque

New Member
Joined
Feb 21, 2005
Messages
1
Hello all,
I'm trying to populate a field based on one of seven values in another field...

eg.

If cell C3 = PC then B3 should = 1
else If cell C3 = MAC then B3 should = 2
else If cell C3 = NB then B3 should = 3
else If cell C3 = MON then B3 should = 4

and so on.

I'm relatively new to Excel so any and all help is appreciated
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Lynque said:
Hello all,
I'm trying to populate a field based on one of seven values in another field...

eg.

If cell C3 = PC then B3 should = 1
else If cell C3 = MAC then B3 should = 2
else If cell C3 = NB then B3 should = 3
else If cell C3 = MON then B3 should = 4

and so on.

I'm relatively new to Excel so any and all help is appreciated

=IF(LOOKUP(C3,{0,"MAC","MON","NB","PC"})=C3,LOOKUP(C3,{0,"MAC","MON","NB","PC"},{"",2,4,3,1}),"")

Or construct a sorted table as shown below...
Book5
CDEFGHI
1TABLE
2ItemNum
3MON440 
4MAC2
5MON4
6NB3
7PC1
8
9
Sheet1


and invoke:

=IF(LOOKUP(C3,$G$3:$G$7)=C3,LOOKUP(C3,$G$3:$H$7),"")

as shown in E4.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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