Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Manpower Calendar Distribution, Skipping weekends.

From the following table, Calendar in Row 1 Starting in Col D,
and Data in Columns A, B, C Starting in Row 2.
I need to distribute the Men, using the Start Date and duration, while
skipping Fridays, saturdays and Sundays. Expected results shown
starting in Column D.
..
.. A B C D E F G H
1. Start Duration Men 7/21 7/22 7/23 7/24 7/25
2. 7/21/2011 2 5 5 5
..
Sub CalDist()
Dim LastRow, LastCol As Long
Dim Dur As Integer ' Duration in Days
Dim Men, d As Integer
Dim Start As String ' Starting Date

LastRow = Range("A65536").End(xlUp).Row
LastCol = Range("IV1").End(xlToLeft).Column + 3

'Populating the Table
For r = 2 To LastRow
Dur = Cells(r, 2)
Men = Cells(r, 3)
For c = 4 To LastCol
Start = Cells(r, 1)
If Start = Cells(1, c) Then
'Distribute Men for the Duration
For d = 0 To Dur - 1
'---------------------------------------------------------------
' If Start Weekday = Friday, Saturday or Sunday, skip the Column
' Problem with the following If's.
' If the Start Date is already a Friday, Saturday or Saturday
' the If's are processed fine.
' If the Start Date is any other WeekDay and the Duration
' would go over the next Week, the If's are ignored.
' I cannot find my Error.
'---------------------------------------------------------------
If Weekday(Cells(1, c)) = 6 Then c = c + 1
If Weekday(Cells(1, c)) = 7 Then c = c + 1
If Weekday(Cells(1, c)) = 1 Then c = c + 1
Cells(r, c + d) = Men
Next d
End If
Next c
Next r
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlighting weekends in a calendar Bill L[_2_] Excel Discussion (Misc queries) 2 February 3rd 09 02:28 PM
Calculate current time + 7 hours and skipping weekends Eric[_2_] Excel Worksheet Functions 3 June 9th 08 02:16 AM
date and time [skipping weekends] rhhince[_2_] Excel Worksheet Functions 8 March 30th 08 08:29 AM
Build a calendar except weekends Mary Excel Discussion (Misc queries) 5 March 7th 07 09:35 PM
How do I set up a clumn of days, skipping weekends? Enrique Excel Worksheet Functions 2 March 2nd 06 10:30 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"