Hi guys
I have been trying to work out a formula for what seems a simple problem, but to no avail. Would really appreciate any help, or even a point in the right direction.
Background
I have a list of data in Excel, over 500 lines in fact, and I need to determine a certain date based on a weekday which follows a different date.
For example:The date I need to determine (the Due Date) is the Cycle Day which follows (or is on) the Process Date.
Process Date Cycle Day Due Date
31/08/2011 Tuesday ??/??/????
31/08/2011 Friday ??/??/????
02/09/2011 Friday ??/??/????
For instance, the correct dates for the above list would be:
At the moment, I'm using a ludicrously complex date array and HLOOKUP, but this isn't suitable for the vast amount lines I have as each line has to be calculated individually. See the attached Excel file.
Process Date Cycle Day Due Date
31/08/2011 Tuesday 06/09/2011
31/08/2011 Friday 02/09/2011
02/09/2011 Friday 02/09/2011
Is there any formula I could use in column C to determine the date I need?
Thanks
Paul
Last edited by batteredveg; 08-24-2011 at 12:47 PM. Reason: Title amendment
Can do this with a user defined function to keep the complexity down.
Open the VBA editor (Alt F11) and a new module (Insert - Module) and paste in the following.
Go back to the sheet (Alt F11) and type in to a cell ..Function DueDate(ProcessDate As Date, WeekDay As String) As Date Dim WeekdayNumber As Integer Select Case WeekDay Case Is = "Monday" WeekdayNumber = 1 Case Is = "Tuesday" WeekdayNumber = 2 Case Is = "Wednesday" WeekdayNumber = 3 Case Is = "Thursday" WeekdayNumber = 4 Case Is = "Friday" WeekdayNumber = 5 End Select DueDate = ProcessDate Do While WorksheetFunction.WeekDay(DueDate, 2) <> WeekdayNumber DueDate = DueDate + 1 Loop End Function
=duedate(A2,B2)
where the process date and week day are in columns A and B respectively. Copy down your 500 rows like any other formula.
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
Fantastic! Thank you for replying; it works perfectly.
Kind regards
Paul
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks