Returning matches from mutiple rows
On Sat, 29 Mar 2008 19:18:00 -0700, Sunshine
wrote:
I use a nursing schedule that shows all nursing staff's schedule for a whole
month. This is referred to as the master schedule.
From this schedule I need to be able to identify specific staff scheduled to
work on a specific day during a specific shift on a daily basis in a separate
worksheet.
So if the master schedule is:
A1 A2 A3 A4
April 1, 2008 April 2, 2008 April 3, 2008
NAME SHIFT SHIFT SHIFT
Debbie 7-3 7-3 Off
Trina 3-11 7-3 7-3
Sherry 7-3 Off 7-3
Lisa 3-11 3-11 3-11
Lewis 7-3 3-11 3-11
Paula Off 7-3 3-11
Sharon 11-7 11-7 11-7
I need a daily schedule for April 1. If I put in that date, it will return
everyone working that day and segregate it by shift. So everyone who is
working 7-3 on April 1 in the first 3 rows, 3-11 the next 3 and ll-7.
This is one way you may try:
Introduce a help column for each shift according to the table below
A1 A2 help 1 A3 help 2 A4 help 3
April 1, 2008 April 2, 2008 April 3, 2008
NAME SHIFT SHIFT SHIFT
Debbie 7-3 7-3_1 7-3 7-3_1 Off Off_1
Trina 3-11 3-11_1 7-3 7-3_2 7-3 7-3_1
Sherry 7-3 7-3_2 Off Off_1 7-3 7-3_2
Lisa 3-11 3-11_2 3-11 3-11_1 3-11 3-11_1
Lewis 7-3 7-3_3 3-11 3-11_2 3-11 3-11_2
Paula Off Off_1 7-3 7-3_3 3-11 3-11_3
Sharon 11-7 11-7_1 11-7 11-7_1 11-7 11-7_1
The formula of cell B4 is like:
=B4&"_"&COUNTIF(B$4:B4,B4) (note the $ in one but only one place)
Copy down to generate all these 7-3_1, 3-11_1, 7-3_2, etc
Assuming that there is no more than 17 nurses and you can use the
space from row 21 and below you can have the following table
generated:
April 2, 2008
7-3 3-11 11-7 Off
Debbie Lisa Sharon Sherry
Trina Lewis #N/A #N/A
Paula #N/A #N/A #N/A
#N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A
The date (April 2, 2008 in this example) is in cell A21
The SHIFT is in cell A22
The formula in cell A23 is like:
=INDEX($A$4:$A$20,MATCH(A$22&"_"&ROW()-22,OFFSET($A$4:$A$20,0,MATCH($A$21,$A$2:$Z$2,0)),0 ))
Copy down as many rows as neeed.
If you don't like the #N/A's you can eliminate them by:
=IFERROR( the formula, "") (Excel 2007 only)
or
=IF(ISERROR( the formula ), "", the formula)
Hope this helps / Lars-Åke
|