Help combining an iF statement with VLOOKUP

Tracy_J

New Member
Joined
Sep 16, 2013
Messages
2
Forgive my ignorance here guys, but I am lost!

I am attempting to input a formula to determine the rate charged for each room rental. My Initial worksheet looks like this. I need to input the rate into column C. The rate is determined by both column B and column E.

ResNoRoom#Daily Room ChargeCustNoRateCode
R0010ALC0001AD
R0010CAC0001AD
R0011COC0002ST
R0012FLC0003ST
R0017ALC0005ST
R0017CAC0005ST
R0017COC0005ST
R0017FLC0005ST
R0017GAC0005ST
R0003CAC0006AD

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>



I have created the lookup table below to determine the dollar amount of the rate.


Room CodeMeeting RoomAD - Advance RateST - Standard RateSP - Special Rate
AUAuditorium$2,418.75$2,925.00$1,735.00
BDBoardroom$1,912.50$2,550.00$1,330.00
CFConference Center$2,475.00$3,200.00$1,900.00
ALAlabama$1,950.00$2,300.00$1,390.00
CACalifornia$1,987.50$2,350.00$1,422.50
COColorado$1,968.75$2,325.00$1,375.00
FLFlorida$1,950.00$2,300.00$1,390.00
GAGeorgia$1,931.12$2,275.00$1,431.25

<colgroup><col><col><col span="3"></colgroup><tbody>
</tbody>


So basically what I need excel to do is say IF (on the 1st worksheet) column B equals AL AND column E equals AD THEN the result is cell C5 in my lookup table (on the second worksheet), but I have no idea how to do this.

Any suggestions?
Thanks!
~T

<tbody>
</tbody>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Welcome to the Board!

If you change your rate codes in the rate table to AD, ST & SP to match the Rate Code on the room worksheet, then you can use something like this:


Excel 2012
ABCDE
1ResNoRoom#Daily Room ChargeCustNoRateCode
2R0010AL$1,950.00C0001AD
3R0010CA$1,987.50C0001AD
4R0011CO$2,325.00C0002ST
5R0012FL$2,300.00C0003ST
6R0017AL$2,300.00C0005ST
7R0017CA$2,350.00C0005ST
8R0017CO$2,325.00C0005ST
9R0017FL$2,300.00C0005ST
10R0017GA$2,275.00C0005ST
11R0003CA$1,987.50C0006AD
Rooms
Cell Formulas
RangeFormula
C2=VLOOKUP(B2,Rates!$A$2:$E$9,MATCH(Rooms!E2,Rates!$A$1:$E$1,0),0)
C3=VLOOKUP(B3,Rates!$A$2:$E$9,MATCH(Rooms!E3,Rates!$A$1:$E$1,0),0)
C4=VLOOKUP(B4,Rates!$A$2:$E$9,MATCH(Rooms!E4,Rates!$A$1:$E$1,0),0)
C5=VLOOKUP(B5,Rates!$A$2:$E$9,MATCH(Rooms!E5,Rates!$A$1:$E$1,0),0)
C6=VLOOKUP(B6,Rates!$A$2:$E$9,MATCH(Rooms!E6,Rates!$A$1:$E$1,0),0)
C7=VLOOKUP(B7,Rates!$A$2:$E$9,MATCH(Rooms!E7,Rates!$A$1:$E$1,0),0)
C8=VLOOKUP(B8,Rates!$A$2:$E$9,MATCH(Rooms!E8,Rates!$A$1:$E$1,0),0)
C9=VLOOKUP(B9,Rates!$A$2:$E$9,MATCH(Rooms!E9,Rates!$A$1:$E$1,0),0)
C10=VLOOKUP(B10,Rates!$A$2:$E$9,MATCH(Rooms!E10,Rates!$A$1:$E$1,0),0)
C11=VLOOKUP(B11,Rates!$A$2:$E$9,MATCH(Rooms!E11,Rates!$A$1:$E$1,0),0)


If you PM me your e-mail address I'll send you an example.

HTH,
 
Upvote 0
this is a bit more complicated than Smitty's answer, but does not require any reformatting of the spreadsheet in case that is not an option.

in column C
=IF(E2="AD",INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23),1),IF(E2="ST",INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23),2),INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23),3)))

The references are based on ResNo being at A1 and RoomCode being at A15, I copy/pasted what was in the post and removed a few lines...
Smitty's answer is quite a bit cleaner then the nested IF statements (personally I don't like nesting like this, but sometimes you have to).

There is another way to to it that is even simpler than either of these if format changes are an opt...
change "AD-..., ST-..., SP-..." to simply say "AD, ST, SP" and use this.

=INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23,0),MATCH(E2,$C$15:$E$15,0))
 
Last edited:
Upvote 0
Thanks! My lookup table is on a separate sheet, however. I have two sheets in my workbook. The first (with my reservation number data) is simply names "sheet 1" and contains 65 rows of information. The second sheet (with my lookup table) is named "Lookup Table" How do I get your formula to reference the lookup table on the second sheet?

Thanks!
~T


this is a bit more complicated than Smitty's answer, but does not require any reformatting of the spreadsheet in case that is not an option.

in column C
=IF(E2="AD",INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23),1),IF(E2="ST",INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23),2),INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23),3)))

The references are based on ResNo being at A1 and RoomCode being at A15, I copy/pasted what was in the post and removed a few lines...
Smitty's answer is quite a bit cleaner then the nested IF statements (personally I don't like nesting like this, but sometimes you have to).

There is another way to to it that is even simpler than either of these if format changes are an opt...
change "AD-..., ST-..., SP-..." to simply say "AD, ST, SP" and use this.

=INDEX($C$16:$E$23,MATCH(B2,$A$16:$A$23,0),MATCH(E2,$C$15:$E$15,0))
 
Upvote 0
Thanks! My lookup table is on a separate sheet, however. I have two sheets in my workbook. The first (with my reservation number data) is simply names "sheet 1" and contains 65 rows of information. The second sheet (with my lookup table) is named "Lookup Table" How do I get your formula to reference the lookup table on the second sheet?

Thanks!
~T

Probably the easiest way is using named ranges. In the MATCH statement, for instance, the named range would replace the array that is being searched. The same is true for the INDEX functions. If the price table was A1:C3 then if you name that price_table and make it workbook, not sheet specific, than anytime you need that range you just need to call its name, from any sheet in the spreadsheet. Sorry I can't give some examples right now, but I am away from the office with my iPad..hope that is enough to get you started though.
 
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,060
Members
449,206
Latest member
Healthydogs

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