On Sep 29, 5:26*pm, shriil <sanjib.lah...@gmail.com> wrote:
> Hi
>
> I have a date column where the fields are incremented by 10 minutes
> starting from 9:00 Hrs to 15:30 Hrs. The column dates are indicated as
> below
>
> A
> sep -23 9:00
> * * * * * * 9:10
> * * * * * * 9:20
> * * * * * * 9:30
> * * * * * * 9:40
> * * * * * * ......
> * * * * * * .....
> * * * * * * 15:20
> * * * * * * 15:30
> sep-24 * 9:00
> * * * * * * *9:10
> * * * * * * * ....
>
> The second condition that needs to be sufficed is if the next date
> falls on a Saturday, then the date shall jump to the next Monday 9:00
> and then continue to be incremented by 10 minutes. This would mean
> that after sep -24 : 15:30 the next date shall have to be sep-27:
> 9:00, as Sep -24 is a Friday and the next date becomes Saturday, so it
> should jump to sep-27 monday.
>
> I have more or less made a formula for say, if sep -24 : 15:30 is in
> Cell (A17) then the formula in Column (A18) shall be
>
> =IF(TIME(HOUR(A17),MINUTE(A17),SECOND(A17))<>TIME(15,30,0),A17+TIME(0,10,0)*,IF(WEEKDAY(A17+TIME(17,30,0))=7,A17+TIME(17,30,0)+TIME(23,0,0)+TIME(1,0,0)*+TIME(23,0,0)+TIME(1,0,0),A17+TIME(17,30,0)))
>
> The formula is then dragged down for all the cells.
>
> The formula is working well but somehow its doesnt seem to a very
> smart formula and is cumbersome.
>
> Can the above logic be inducted in a better formula?
Yes.
Consider first putting any constants into its own cell. This reduces
the active cells function length, & also makes changes easy (think
what you would have to do if the the day ended with 15:20 instead of
15:30).
These constants could be put into hidden rows/columns or put outside
the Print Area. This also would allow you to put comments against them
("Magic Numbers" ie numbers which have no inherent meaning) are not
understood after 6 months (the Six Month Rule).
So put :
Column A B
Row 1 Start Date 23/9/2010
2 Day End =Time(9.0,0)
3 Day End = Time(15,30,0)
4 Increment = Time(0,10,0)
The date-time values in Excel are formated as an integer for the days
and a decimal fraction for the time. So INT(<day-value>) returns the
day. There is no function FRAC() to return the time (at least in my
Excel) so one must use <day-value> - INT(<day-value).
So to the active cells :
Column B
Row 6 & on =IF(INT(B6)=INT(B5),0,B6)
Column C
Row 6 =B1+B2
Column C
Row 7 & on =IF(B6-INT(B6)>$B$3,INT(B6)+IF(WEEKDAY(B6,1)=6,3,1)+$B$2,B6+
$B$4)
That is :
If (PreviousCell date-time - PreviousCell date) > Day End then
PreviousCell + If(PreviousCell is Friday, 3 else 1) + Increment
else
PreviousCell + Increment.
Then format active column A as : mmm dd;"";""
Format active column B as h:mm
Alan Lloyd