Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Thanks for the time spent on that. I am a novice to macros though so any
directions would be great if possible. Regards "Mike H." wrote: I tried to do it as calculation in a cell but it gets too cumbersome. But this code, which I created in about 10 minutes work fine. The only thing you might want adjusted is that it can end at 5pm the following day if you start at 5 pm the current day. I don't know about that but test it out. If you don't know how to set up this as a macro let me know.... Sub CalcIt() Dim InTime As Double Dim AddTo As Double Dim EndMoment As Double Dim Priority As Integer Dim TheRow As Double Let TheRow = ActiveCell.Row Let InTime = Cells(TheRow, 5) 'E38 Let Priority = Cells(TheRow, 7) 'G38 If Hour(InTime) 17 Then Let InTime = Int(InTime) + (17 / 24) 'sets to 5pm. End If If Priority = 1 Then Let AddTo = 0.083333 ElseIf Priority = 2 Then Let AddTo = 0.166666667 ElseIf Priority = 3 Then Let AddTo = 1 ElseIf Priority = 4 Then Let AddTo = 2 ElseIf Priority = 5 Then Let AddTo = 7 End If Let EndMoment = InTime + AddTo If Hour(EndMoment) 17 Then 'if end time is after 5 pm then must go to next day 'Let AddTo = Hour(EndMoment) - 17 Let EndMoment = Int(EndMoment) Let EndMoment = EndMoment + 1 + (9 / 24) + AddTo 'move to 9 am next day End If If Weekday(EndMoment) = 6 Then Let EndMoment = EndMoment + 2 ElseIf Weekday(EndMoment) = 7 Then Let EndMoment = EndMoment + 1 End If Cells(TheRow, 8).Value = EndMoment End Sub |