First of all the link to the other post:
http://www.mrexcel.com/forum/showthread.php?p=2507031#post2507031
That solution is different to the one below but with similar formulas and, as you can see from the latest post, I will be adding to it.
Here are te formulas and instructions to give you a solution for Excel 2007/2010 that have the "IFERROR" function. Once you have confirmed that you have got it working the way you want, I will then provide the more lengthy formulas that will work for any version of Excel.
At first glance this may look complicated, but it is not - it is just that there is a lot of descriptive text. I recommend that you Copy/Paste the formulas to avoid typing errors.
First of all, an assumption: that cell A1 is blank (as in the example that you provided). If you do add something there later, it will be necessary to adjust formulas.
I will refer to your data sheet by the name "Master Sheet" - you will see that this is enclosed in single quotes in formulas because of the space in the name.
No changes are required to the Master Sheet - the formulas are required on the other sheets.
Step 1. Create a worksheet named "Control Sheet".
The name is not significant - most of my workbooks have such a sheet with a meaningful name. Here we will place a small table.
Cell A1: Type the name "Abbreviation".
Cell B1: Type the name "Day".
In each of Cells A2 to A8, enter the abbreviations that you have used in Row 1 on the Master Sheet. e.g SU, M, T, W, TH, F, S
In each of Cells B2 to B8 enter the full names for the days in Column A (e.g. Sunday, Monday etc.).
Select cells A2:B8 and give the range a 'name'. Do this by entering the name "WeekdayList" (without the quotes - note that there can be no spaces) and then making sure that you press 'Enter' (very important).
Step 2. Create a new worksheet and give it the name "1".
Step 3. Enter the following formula in cell E1:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)*1
The "*1" is required to ensure that the result is a number and not text. You will now see that the cell shows the name of the worksheet ("1" in this case).If you prefer to have a different name for the worksheet, that is OK but you will then have to enter the appropriate day number in cell E1.
Step 4. Enter the following formula in cell A1:
=COUNTA('Master Sheet'!A:A)+1
If you later enter something in A1 on the MASTER Sheet, then you will need to remove the "+1" from this formula. This shows the last row number in the MASTER Sheet and will change as you add and remove names.
Step 5. Enter the following formula in cell F1:
=VLOOKUP(INDEX('Master Sheet'!$B$1:$AF$1,1,MATCH($E$1,'Master Sheet'!$B$2:$AF$2,0)),WeekdayList,2,FALSE)
This will give you the day of the week to match the day number in cell E1.
Step 6. Enter the following values in the cells indicated:
A2: M
B2: E
C2: N
D2: L
E2: Morning
F2: Evening
G2: Night
H2: Leave
Step 6. Enter the following formula in cell A3:
=IFERROR(MATCH(A$2,OFFSET('Master Sheet'!$A$1,2,MATCH($E$1,'Master Sheet'!$B$2:$AF$2,0),COUNTA('Master Sheet'!$A:$A)-1,1),0)+2,"")
Now copy that formula across to cells B3, C3 and D3
This formula will show the row in which the
first instance of the value in row 2 will be found - in the example that you gave it would show that the first instance of "M" for Day 1 will be found on Row 3.
Step 7. Enter a slightly different formula in cell A4:
=IFERROR(MATCH(A$2,OFFSET('Master Sheet'!$A$1,A3,MATCH($E$1,'Master Sheet'!$B$2:$AF$2,0),COUNTA('Master Sheet'!$A:$A)-1,1),0)+A3,"")
Copy this formula across to cells B4, C4 and D4.
ALSO now copy-down the formulas in A4:D4 as far as you need - this needs to be far enough to be able to show all the names in the MASTER Sheet. You can go beyond this if you want to but, one very important point, is that if you later want to print this sheet make sure that the Print Area includes the data only and not the rows that have formulas but no data.
Cells A4:D4 and downwards will show the row number for the "next" required name for the value in row 2.
Step 8. Enter the following formula in E3:
=IFERROR(INDEX(OFFSET('Master Sheet'!$A$1,0,0,$A$1,1),A3,1),"")
Copy this formula across as far as H3 and then down as far as you went with the formulas in Step 7.
Step 9. When you have checked and tested the worksheet, you can hide columns A, B, C and D.
Step 10. To create other worksheets, copy the one that has just been created (hold down the Ctrl key, left mouse-click the tab and drag it to the right). For example you will now get a sheet with the name "1 (2)" - rename the worksheet to "2" and that will now show the data for the second day. It is as simple as that - copy worksheet, change the worksheet name.
Finally. Let me know if I have missed anything or anything is not clearly explained. When it is working OK, I will give you the formulas for all versions of Excel.