Help make this formula more elegant

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
Hi

I've got this formula which works correctly but is a bit long winded and has a few nested IF statements;

=IF(G7="eombh",INDEX(E2:E22,MATCH(1,(G2=A2:A22)*(G3=B2:B22),0)),IF(G7="eom",INDEX(D2:D22,MATCH(1,(G2=A2:A22)*(G3=B2:B22),0)),(INDEX(C2:C22,MATCH(1,(G2=A2:A22)*(G3=B2:B22),0)))))

G2= system
G3 = Day
G7="eombh etc"


[TABLE="width: 500"]
<tbody>[TR]
[TD]System A
[/TD]
[TD]Monday[/TD]
[TD]08:00[/TD]
[TD]08:15[/TD]
[TD]09:00[/TD]
[/TR]
[TR]
[TD]System A[/TD]
[TD]Tuesday[/TD]
[TD]08:30[/TD]
[TD]08:45[/TD]
[TD]09:15[/TD]
[/TR]
[TR]
[TD]System B[/TD]
[TD]Monday[/TD]
[TD]07:00[/TD]
[TD]07:15[/TD]
[TD]08:15[/TD]
[/TR]
[TR]
[TD]System B[/TD]
[TD]Tuesday[/TD]
[TD]07:30[/TD]
[TD]07:45[/TD]
[TD]08:50[/TD]
[/TR]
</tbody>[/TABLE]

can anyone help with simplify it?

many thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
can anyone help with simplify it?

Hi, if you put the possible values of G7 into the appropiate columns header of your lookup table you can use something like this.


Excel 2013/2016
ABCDEFGHI
1othereomeombh
2System AMonday08:0008:1509:00System A08:45:00
3System ATuesday08:3008:4509:15Tuesday
4System BMonday07:0007:1508:15
5System BTuesday07:3007:4508:50
6
7eom
Sheet1
Cell Formulas
RangeFormula
I2{=INDEX($C$2:$E$5,MATCH(1,(A2:A22=G2)*(B2:B22=G3),0),MATCH(G7,C1:E1,0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Maybe this?

=INDEX(C2:E22,MATCH(1,INDEX((A2:A22=G2)*(B2:B22=G3),0),0),IFERROR(VLOOKUP(G7,{"eombh",3;"eom",2},2,0),1))
 
Upvote 0
Hi, if you put the possible values of G7 into the appropiate columns header of your lookup table you can use something like this.

Excel 2013/2016
ABCDEFGHI
othereomeombh
System AMondaySystem A
System ATuesdayTuesday
System BMonday
System BTuesday
eom

<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]08:00[/TD]
[TD="align: right"]08:15[/TD]
[TD="align: right"]09:00[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]08:45:00[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]08:30[/TD]
[TD="align: right"]08:45[/TD]
[TD="align: right"]09:15[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]07:00[/TD]
[TD="align: right"]07:15[/TD]
[TD="align: right"]08:15[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]07:30[/TD]
[TD="align: right"]07:45[/TD]
[TD="align: right"]08:50[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]I2[/TH]
[TD="align: left"]{=INDEX($C$2:$E$5,MATCH(1,(A2:A22=G2)*(B2:B22=G3),0),MATCH(G7,C1:E1,0))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]

Yeah that did the job nicely, many thanks
 
Upvote 0
I wonder if anyone could simplify the first part of the formula which determines what is in cell G7

=IF(AND(ISNUMBER(MATCH(I2,M2:M7,0)),ISNUMBER(MATCH(I2,J2,0))),"eombh",IF(ISNUMBER(MATCH(I2,J2,0)),"eom",IF(ISNUMBER(MATCH(I2,M2:M7,0)),"bh","normal")))

[TABLE="width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]EOM[/TD]
[TD]Bank Holiday Dates[/TD]
[/TR]
[TR]
[TD]26/02/2019[/TD]
[TD]28/02/2019[/TD]
[TD]02/03/2019[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]04/03/2019[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
=IF(AND(ISNUMBER(MATCH(I2,M2:M7,0)),ISNUMBER(MATCH(I2,J2,0))),"eombh",IF(ISNUMBER(MATCH(I2,J2,0)),"eom",IF(ISNUMBER(MATCH(I2,M2:M7,0)),"bh","normal")))

Hi, I think this is equivalent.

=IF(ISNUMBER(MATCH(I2,M2:M7,0)),IF(I2=J2,"eombh","bh"),IF(I2=J2,"eom","normal"))
 
Upvote 0
can i somehow get another query in front of;

=IF(ISNUMBER(MATCH(J2,N2:N7,0)),IF(J2=K2,"eombh","bh"),IF(J2=K2,"eom","normal"))

to first look at system H2 then compare the possible bank holiday dates in N2:P7

=IF(MATCH(H2,N1:P1,0),IF(ISNUMBER(MATCH(J2,$N$2:$P$7,0)),IF(J2=K2,"eombh","bh"),IF(J2=K2,"eom","normal")))

but this is not returning the correct result like the first formula

any ideas?
 
Upvote 0
to first look at system H2 then compare the possible bank holiday dates in N2:P7

Hi, what should be returned when there is a match to the bank holiday dates - what should be returned when there isn't?
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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