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
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,201
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,321
Messages
5,600,950
Members
414,417
Latest member
Nobu

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
Top