# Help make this formula more elegant

#### ireland87

##### Board Regular
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 Monday 08:00 08:15 09:00 System A Tuesday 08:30 08:45 09:15 System B Monday 07:00 07:15 08:15 System B Tuesday 07:30 07:45 08:50

<tbody>
</tbody>

can anyone help with simplify it?

many thanks

### 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
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>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />

#### steve the fish

##### Well-known Member
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
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
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")))

 Date EOM Bank Holiday Dates 26/02/2019 28/02/2019 02/03/2019 04/03/2019

<tbody>
</tbody>

#### FormR

##### MrExcel MVP
=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
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
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
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?

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...