Multiple VLOOKUP formulas in ONE cell

guscy

Board Regular
Joined
Jun 13, 2016
Messages
54
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I am trying to organize a weekly work schedule. Working hours are standard each week. I would like to select between T_1 and T_2 in cell B2, B3, B4..., and automatically cells C2:I2 auto fill with working hours according tables. Selection T_1 is for table 1 and selection T_2 for table 2.

I manage to have it work only for T_1. If I select T_2 I get FALSE.

I would appreciate your help!

Thanks


Book1
ABCDEFGHI
1SELECT TABLEMONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAY
2NAME 1T_17:00-15:00DAY OFF13:30-21:309:00-16:309:00-16:308:00-16:009:00-15:00
3NAME 2T_17:00-15:00DAY OFF13:30-21:309:00-16:309:00-16:308:00-16:009:00-15:00
4NAME 3T_2FALSEFALSEFALSEFALSEFALSEFALSEFALSE
5
6TABLE 1TABLE 2
7T_1T_2TABLES
8MONDAY7:00-15:00MONDAY7:00-15:00T_1
9TUESDAYDAY OFFTUESDAY9:00-16:30T_2
10WEDNESDAY13:30-21:30WEDNESDAY13:00-21:30
11THURSDAY9:00-16:30THURSDAY9:00-15:30
12FRIDAY9:00-16:30FRIDAY9:00-16:00
13SATURDAY8:00-16:00SATURDAY9:00-16:30
14SUNDAY9:00-15:00SUNDAYDAY OFF
Sheet1
Cell Formulas
RangeFormula
C2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(C1,T_1,2,IF($B$2="T_2",VLOOKUP(C1,TBL_S_2,2,FALSE)))))
C3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(C1,T_1,2,IF($B$3="T_2",VLOOKUP(C1,T_2,2,FALSE)))))
C4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(C1,T_1,2,IF($B$4="T_2",VLOOKUP(C1,T_2,2,FALSE)))))
D2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(D1,T_1,2,IF($B$2="T_2",VLOOKUP(D1,TBL_S_2,2,FALSE)))))
D3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(D1,T_1,2,IF($B$3="T_2",VLOOKUP(D1,T_2,2,FALSE)))))
D4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(D1,T_1,2,IF($B$4="T_2",VLOOKUP(D1,T_2,2,FALSE)))))
E2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(E1,T_1,2,IF($B$2="T_2",VLOOKUP(E1,TBL_S_2,2,FALSE)))))
E3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(E1,T_1,2,IF($B$3="T_2",VLOOKUP(E1,T_2,2,FALSE)))))
E4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(E1,T_1,2,IF($B$4="T_2",VLOOKUP(E1,T_2,2,FALSE)))))
F2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(F1,T_1,2,IF($B$2="T_2",VLOOKUP(F1,TBL_S_2,2,FALSE)))))
F3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(F1,T_1,2,IF($B$3="T_2",VLOOKUP(F1,T_2,2,FALSE)))))
F4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(F1,T_1,2,IF($B$4="T_2",VLOOKUP(F1,T_2,2,FALSE)))))
G2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(G1,T_1,2,IF($B$2="T_2",VLOOKUP(G1,TBL_S_2,2,FALSE)))))
G3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(G1,T_1,2,IF($B$3="T_2",VLOOKUP(G1,T_2,2,FALSE)))))
G4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(G1,T_1,2,IF($B$4="T_2",VLOOKUP(G1,T_2,2,FALSE)))))
H2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(H1,T_1,2,IF($B$2="T_2",VLOOKUP(H1,TBL_S_2,2,FALSE)))))
H3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(H1,T_1,2,IF($B$3="T_2",VLOOKUP(H1,T_2,2,FALSE)))))
H4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(H1,T_1,2,IF($B$4="T_2",VLOOKUP(H1,T_2,2,FALSE)))))
I2=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(I1,T_1,2,IF($B$2="T_2",VLOOKUP(I1,TBL_S_2,2,FALSE)))))
I3=IF(ISBLANK($B$3)," ",IF($B$3="T_1",VLOOKUP(I1,T_1,2,IF($B$3="T_2",VLOOKUP(I1,T_2,2,FALSE)))))
I4=IF(ISBLANK($B$4)," ",IF($B$4="T_1",VLOOKUP(I1,T_1,2,IF($B$4="T_2",VLOOKUP(I1,T_2,2,FALSE)))))
Named Ranges
NameRefers ToCells
T_1=Sheet1!$A$8:$B$14
T_2=Sheet1!$D$8:$E$14
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
It looks like you're missing a parameter and parenthesis
=IF(ISBLANK($B$2)," ",IF($B$2="T_1",VLOOKUP(C1,T_1,2,False),IF($B$2="T_2",VLOOKUP(C1,TBL_S_2,2,FALSE)))))

However, This is a good use for the indirect formula instead of IF's. The indirect formula basically converts a string into a reference
=Iferror(Vlookup(C1,Indirect($B2),2,false)),"")

So if B2 contains "T_2" then
Indirect(B2)
Will look at the range T_2
 
Upvote 0
Really thanks!!!

Formula with IF, worked!

What about INDIRECT function? What is the formula?
 
Upvote 0
Really thanks!!!

Formula with IF, worked!

What about INDIRECT function? What is the formula?

Indirect converts a string into an actual range
So if A1 contains: T_1
then
Indirect(A1)
looks at the named range "T_1"
 
Last edited:
Upvote 0
Ok thanks! I will use formula with INDIRECT because is more easy. I had no idea about it!
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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