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"


System A
Monday08:0008:1509:00
System ATuesday08:3008:4509:15
System BMonday07:0007:1508:15
System BTuesday07:3007:4508:50

<tbody>
</tbody>

can anyone help with simplify it?

many thanks
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,413
Office Version
365
Platform
Windows
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.

<b>Excel 2013/2016</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">other</td><td style=";">eom</td><td style=";">eombh</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style="color: #333333;;">System A</td><td style="color: #333333;;">Monday</td><td style="text-align: right;color: #333333;;">08:00</td><td style="text-align: right;color: #333333;;">08:15</td><td style="text-align: right;color: #333333;;">09:00</td><td style="text-align: right;;"></td><td style=";">System A</td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #FFFF00;;">08:45:00</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style="color: #333333;;">System A</td><td style="color: #333333;;">Tuesday</td><td style="text-align: right;color: #333333;;">08:30</td><td style="text-align: right;color: #333333;;">08:45</td><td style="text-align: right;color: #333333;;">09:15</td><td style="text-align: right;;"></td><td style=";">Tuesday</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="color: #333333;;">System B</td><td style="color: #333333;;">Monday</td><td style="text-align: right;color: #333333;;">07:00</td><td style="text-align: right;color: #333333;;">07:15</td><td style="text-align: right;color: #333333;;">08:15</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style="color: #333333;;">System B</td><td style="color: #333333;;">Tuesday</td><td style="text-align: right;color: #333333;;">07:30</td><td style="text-align: right;color: #333333;;">07:45</td><td style="text-align: right;color: #333333;;">08:50</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">eom</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I2</th><td style="text-align:left">{=INDEX(<font color="Blue">$C$2:$E$5,MATCH(<font color="Red">1,(<font color="Green">A2:A22=G2</font>)*(<font color="Green">B2:B22=G3</font>),0</font>),MATCH(<font color="Red">G7,C1:E1,0</font>)</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,080
Office Version
365
Platform
Windows
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))
 

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
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

<tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
I2{=INDEX($C$2:$E$5,MATCH(1,(A2:A22=G2)*(B2:B22=G3),0),MATCH(G7,C1:E1,0))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
Yeah that did the job nicely, many thanks
 

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
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")))

DateEOMBank Holiday Dates
26/02/201928/02/201902/03/2019
04/03/2019

<tbody>
</tbody>
 

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,413
Office Version
365
Platform
Windows
=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"))
 

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
Hi, I think this is equivalent.

=IF(ISNUMBER(MATCH(I2,M2:M7,0)),IF(I2=J2,"eombh","bh"),IF(I2=J2,"eom","normal"))
Thank you very much! works a treat :)
 

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
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?
 

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,413
Office Version
365
Platform
Windows
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,102,872
Messages
5,489,404
Members
407,687
Latest member
NeoSez

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top