Using INDEX and MATCH with two arguments, allowing up to four results

johnburgin

New Member
Joined
Feb 8, 2013
Messages
33
Hi,

i have a spreadsheet which contains information about booked appointments, for up to six officers. I now need to build a 2 weekly diary summary sheet. I need to match the officer against their appointments for the day.

So, Monday would list underneath up to four names of clients booked, Tuesday the same and so on.

I need to match, therefore, the officer with the date, and return the client name.

So far, I have learnt how to match an officer and use index to return the client name using:

=index(drange,match("FM",qrange,false))

where "FM" is the officer's name, drange contains client names and qrange contains the officer's initials.

Booking dates are stored in rrange.

But I need to be able to match the above for a specified date contained in cell A2.

Also, there may be up to four appointments booked for that date, so I plan on using the formula in four cells, each returning the next booking.

Finally, I would prefer not to use arrays IF POSSIBLE so as to avoid slowing the spreadsheet down.

Im using Excel 2003.

Thanks for your help.

JB
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
johnburgin,

In the absence of any other responses here is my take on this.
Unless you were to use vba to compile your summary then array formulas are unavoidable.

I do not know how you intend laying out your summary but the below might give you ideas if nothing else.

Have assumed yournamed ranges to be in eg 'Diary' sheet and summary on 'Summary' sheet.

Date of first day of summary in cell D3 the other day/dates by formula eg =D3+1 etc.

The formula in C3 will copy down 4 appointmet row and across for two weeks of dates.

However the next block of data for the second officer will require an edit to increment the
ROWS($A$3:$A3) and the qrange=$A$3 elements to ROWS($A$8:$A8) and the qrange=$A$8

Similarly, add 5 for each subsequent officer block.



Excel 2007
CDE
2DateClientOfficer
301/01/2013AAS
404/01/2013BFM
503/01/2013AHY
602/01/2013CFM
704/01/2013DWE
804/01/2013PHY
904/01/2013GWE
1004/01/2013XWE
1104/01/2013TFM
1205/01/2013LWE
1305/01/2013MFM
1406/01/2013ZFM
1506/01/2013KFM
1606/01/2013CWE
1706/01/2013VFM
Diary



Excel 2007
ABCDE
1
2Officer04/01/201305/01/201306/01/2013
3FMApp 1BMZ
4App 2TK
5App 3V
6App 4
7
8WEApp 1DLC
9App 2G
10App 3X
11App 4

<COLGROUP><COL><COL><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
Summary

Array Formulas
CellFormula
C3{=IF(ROWS($A$3:$A3)>SUMPRODUCT((qrange=$A$3)*(rrange=C$2)),"",INDEX(drange,MATCH(LARGE((qrange=$A$3)*(rrange=C$2)*(50000-ROW(rrange)),ROWS($A$3:$A3)),(qrange=$A$3)*(rrange=C$2)*(50000-ROW(rrange)),0),1))}

<THEAD>
</THEAD><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>

Workbook Defined Names
NameRefers To
drange=Diary!$D$3:$D$17
qrange=Diary!$E$3:$E$17
rrange=Diary!$C$3:$C$17

<THEAD>
</THEAD><TBODY>
</TBODY>

<TBODY>
</TBODY>





I hope that makes sense and is of some help.
 
Upvote 0
Yes, that's excellent, thanks. How does the reference to 50000-row work exactly?

JB

johnburgin,

In the absence of any other responses here is my take on this.
Unless you were to use vba to compile your summary then array formulas are unavoidable.

I do not know how you intend laying out your summary but the below might give you ideas if nothing else.

Have assumed yournamed ranges to be in eg 'Diary' sheet and summary on 'Summary' sheet.

Date of first day of summary in cell D3 the other day/dates by formula eg =D3+1 etc.

The formula in C3 will copy down 4 appointmet row and across for two weeks of dates.

However the next block of data for the second officer will require an edit to increment the
ROWS($A$3:$A3) and the qrange=$A$3 elements to ROWS($A$8:$A8) and the qrange=$A$8

Similarly, add 5 for each subsequent officer block.


Excel 2007
CDE
2DateClientOfficer
301/01/2013AAS
404/01/2013BFM
503/01/2013AHY
602/01/2013CFM
704/01/2013DWE
804/01/2013PHY
904/01/2013GWE
1004/01/2013XWE
1104/01/2013TFM
1205/01/2013LWE
1305/01/2013MFM
1406/01/2013ZFM
1506/01/2013KFM
1606/01/2013CWE
1706/01/2013VFM

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Diary




Excel 2007
ABCDE
1
2Officer04/01/201305/01/201306/01/2013
3FMApp 1BMZ
4App 2TK
5App 3V
6App 4
7
8WEApp 1DLC
9App 2G
10App 3X
11App 4

<tbody>
</tbody>
Summary

Array Formulas
CellFormula
C3{=IF(ROWS($A$3:$A3)>SUMPRODUCT((qrange=$A$3)*(rrange=C$2)),"",INDEX(drange,MATCH(LARGE((qrange=$A$3)*(rrange=C$2)*(50000-ROW(rrange)),ROWS($A$3:$A3)),(qrange=$A$3)*(rrange=C$2)*(50000-ROW(rrange)),0),1))}

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

Workbook Defined Names
NameRefers To
drange=Diary!$D$3:$D$17
qrange=Diary!$E$3:$E$17
rrange=Diary!$C$3:$C$17

<tbody>
</tbody>

<tbody>
</tbody>





I hope that makes sense and is of some help.
 
Upvote 0
Hi,

i have a spreadsheet which contains information about booked appointments, for up to six officers. I now need to build a 2 weekly diary summary sheet. I need to match the officer against their appointments for the day.

So, Monday would list underneath up to four names of clients booked, Tuesday the same and so on.

I need to match, therefore, the officer with the date, and return the client name.

So far, I have learnt how to match an officer and use index to return the client name using:

=index(drange,match("FM",qrange,false))

where "FM" is the officer's name, drange contains client names and qrange contains the officer's initials.

Booking dates are stored in rrange.

But I need to be able to match the above for a specified date contained in cell A2.

Also, there may be up to four appointments booked for that date, so I plan on using the formula in four cells, each returning the next booking.

Finally, I would prefer not to use arrays IF POSSIBLE so as to avoid slowing the spreadsheet down.

Im using Excel 2003.

Thanks for your help.

JB

Sheet2, the destination sheet...

A1 houses an initial like FM...
A2 houses a date of interest...

A3, control+shift+enter:

=SUM(IF(qrange=A$1,IF(rrange=A$2,1)))

A4: Client

A5, control+shift+enter, and copy down:

=IF(ROWS(A$5:A5)<=A$3,INDEX(drange,SMALL(IF(qrange=A$1,IF(rrange=A$2,ROW(drange)-ROW(INDEX(drange,1,1))+1)),ROWS(A$5:A5)),"")
 
Upvote 0
Yes, that's excellent, thanks. How does the reference to 50000-row work exactly?

JB


JB,

Here is my thinking on the 500000.

The (qrange=$A$3)*(rrange=C$2) portion of the formula will yield an array of zeros and ones.
Adding *(ROW(rrange) keeps the zeros and turn the ones into unique numbers ie row numbers.

I wanted to avoid using SMALL because of all the zeros. Using LARGE without the 50000- will give you a result if you try it but the appointments will be in the reverse order. Eg in my example for WE on the 04/01/2013, appointments D, G, X would invert to be X, G, D. Thinking that appointment 1 would be above appointment 2, etc, in your diary data, I used 50000 as an arbitrary large number so that 50000-Row.... would preserve the order of appointments.

Once again, I hope that makes sense.
 
Upvote 0

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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