Solved

# Excel formula question

Posted on 2011-10-25
Medium Priority
256 Views
Last Modified: 2012-05-12
Hello,

Let's say you are using an Excel spreadsheet for the purpose of making assignments in a group of people for the next 12 months to do some task once each month.

In the spreadsheet, suppose column C contains sequential dates of the month and column B contains a number indicating how many times that particular day has occurred that month (Fig. 1).
(Note that rows 13 thru 33 have been hidden in Fig. 1)

For example:

• Cell B5 = 1, indicating that October 3rd is the 1st Monday of the month,
• Cell B10 = 2, indicating that October 8th is the 2nd Saturday of the month,
• Cell B12 = 2, indicating that October 10th is the 2nd Monday of the month,
• and so on.

Also, suppose that the same spreadsheet contains a table of names (Fig. 2), in which columns G:M are headed by the seven days of the week and column F contains 1st thru 5th (corresponding to the numbering in column B) to designate to which occurrence of a particular day each person is assigned.

What formula would accurately populate column D (Figs. 3 & 4) with the correct names from the table?

(Note:  All Figs. show the same spreadsheet.  Figs. 2 & 3 show the assignment columns and the table separately [so they are easier to see] whereas Fig. 4 shows both of them together.)
(Note that rows 13 thru 33 have been hidden in Fig. 3)

For example, the table indicates that:

• Gary has the 1st Friday of each month so his name should be displayed for Oct 7, Nov 4, etc.
• Paul has the 1st Saturday of each month so his name should be displayed for Oct 1, Nov 5, etc.
• Dave has the 2nd Saturday of each month so his name should be displayed for Oct 8, Nov 12, etc.
• and so on
(Note that rows 13 thru 33 have been hidden in Fig. 4)

Thanks
0
Question by:Steve_Brady
• 7
• 6
• 4
17 Comments

LVL 43

Expert Comment

ID: 37029048
Can you upload a part of your spreadsheet. It is important to know how you have entered the dates.
0

LVL 43

Expert Comment

ID: 37029080
Try one of these formulas

=INDEX(\$G\$2:\$M\$6,\$B3,MATCH(TEXT(C4,"ddd"),LEFT(\$G\$1:\$M\$1,3),0))
=INDEX(\$G\$2:\$M\$6,\$B3,MATCH(LEFT(\$C3,3),LEFT(\$G\$1:\$M\$1,3),0))
0

LVL 26

Accepted Solution

redmondb earned 2000 total points
ID: 37029103
Steve,

Please see attached. There are two sheets - "String" assumes that the date is simply a string as shown, whereas "Date" assumes it's a formatted date, take your pick!

I've cheated and abbreviated the names of the days in the table. Obviously that can be easily changed if necessary.

My formulas are highlighted in yellow -
"String"
=IF(B3="","",OFFSET(\$F\$1,A3,MATCH(TRIM(MID(B3,1,FIND(",",B3,1)-1)),\$G\$1:\$M\$1,0)))
"Date"
=IF(B3="","",OFFSET(\$F\$1,A3,MATCH(TEXT(B3,"ddd"),\$G\$1:\$M\$1,0)))

Regards,
Brian.
Assignments.xls
0

LVL 43

Expert Comment

ID: 37029109
I forgot to mention that the formulas I have provided are array formulas and should be entered by pressing ctrl-shift-enter.
0

Author Comment

ID: 37029120
Thanks for the response.

>>It is important to know how you have entered the dates.

Formatting for the date column is:  ddd, mmm dd.  The dates were created simply by entering "10/1/2011" in cell C3, then "=C3+1" in cell C4 and pasting it down.   Everything else was entered manually.
0

LVL 43

Expert Comment

ID: 37029121
Then you can try my first formula
0

LVL 26

Expert Comment

ID: 37029125
Or my "Date" sheet. :)
0

Author Comment

ID: 37029141
>>ssaqibh:
Try one of these formulas

Try them by pasting in which cell?

Neither formula appears to work:

1st formula puts Paul in cell D10.  2nd Saturday is Dave.
2nd formula results in #N/A
0

LVL 26

Expert Comment

ID: 37029147
Steve,

I compared my results to yours and they agreed. Please look at the file!

Thanks,
Brian.
0

Author Comment

ID: 37029160
>>redmondb:
Please see attached.

That's it Brian!  I had the first part using =OFFSET() but I needed help with setting up the =MATCH().

Thanks a bunch!  :)
0

LVL 26

Expert Comment

ID: 37029164
Excellent, glad you're happy!
0

Author Comment

ID: 37029170
And you even included:

=IF(B3="",""

That was going above and beyond!  LOL
0

LVL 26

Assisted Solution

redmondb earned 2000 total points
ID: 37029172
BTW, simple change to the formula if you want the full day names in the table...

=IF(B3="","",OFFSET(\$F\$1,A3,MATCH(TEXT(B3,"dddd"),\$G\$1:\$M\$1,0)))
0

LVL 26

Expert Comment

ID: 37029175
Well, you are paying for the Premium service!
0

Author Comment

ID: 37029217
>>>BTW, simple change...

Yep, just spotted that too.

BTW, your response and the one from ssaqibh just brought up a question I'm always wondering regarding when to use  =Match() vs. =Index().  However, I will close this out and post that in a separate thread.

Thanks again.
0

Author Closing Comment

ID: 37029218
Thanks
0

LVL 26

Expert Comment

ID: 37029265
Thanks, Steve.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
###### Suggested Courses
Course of the Month12 days, 19 hours left to enroll

#### 578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.