PC Review


Reply
Thread Tools Rate Thread

Build DateSeries (?)

 
 
sgl
Guest
Posts: n/a
 
      3rd Jan 2008
Hi All,

I have the following range of dates/times

Start Date 1 Jan 08 12:00 hrs
End Date 21 Nov 08 09:30 hrs
Increment by 15 days

Need to develop a VBA routine that builds a two column series as follows
Col A ColB
StartDate StartDate + Increment
StartDate + Increment StartDate + Increment + Increment
etc
to EndDate

Calculating the total time between dates in each row should give you a total
time between SatrtDate and EndDate of 324.8958333 Days. As validation I will
need to calcualte the total time between dates in each Row
Can anyone assist me in this please!
Many thanks/sgl

 
Reply With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      3rd Jan 2008
Hi,

I don't think you really need any VBA for this if it's just a one-off. Why
don't you just put "01/01/08 12:00:00" in cell A2, and then put the formula
'=A2+15' in A3 and drag it down as far as you want etc?

Sam

"sgl" wrote:

> Hi All,
>
> I have the following range of dates/times
>
> Start Date 1 Jan 08 12:00 hrs
> End Date 21 Nov 08 09:30 hrs
> Increment by 15 days
>
> Need to develop a VBA routine that builds a two column series as follows
> Col A ColB
> StartDate StartDate + Increment
> StartDate + Increment StartDate + Increment + Increment
> etc
> to EndDate
>
> Calculating the total time between dates in each row should give you a total
> time between SatrtDate and EndDate of 324.8958333 Days. As validation I will
> need to calcualte the total time between dates in each Row
> Can anyone assist me in this please!
> Many thanks/sgl
>

 
Reply With Quote
 
sgl
Guest
Posts: n/a
 
      3rd Jan 2008
Hi Sam,

Thanks for your quick response. I need to develop a VBA code as this is part
of a much larger project that needs substantial automation for the users.
Thanks anyway./sgl


"Sam Wilson" wrote:

> Hi,
>
> I don't think you really need any VBA for this if it's just a one-off. Why
> don't you just put "01/01/08 12:00:00" in cell A2, and then put the formula
> '=A2+15' in A3 and drag it down as far as you want etc?
>
> Sam
>
> "sgl" wrote:
>
> > Hi All,
> >
> > I have the following range of dates/times
> >
> > Start Date 1 Jan 08 12:00 hrs
> > End Date 21 Nov 08 09:30 hrs
> > Increment by 15 days
> >
> > Need to develop a VBA routine that builds a two column series as follows
> > Col A ColB
> > StartDate StartDate + Increment
> > StartDate + Increment StartDate + Increment + Increment
> > etc
> > to EndDate
> >
> > Calculating the total time between dates in each row should give you a total
> > time between SatrtDate and EndDate of 324.8958333 Days. As validation I will
> > need to calcualte the total time between dates in each Row
> > Can anyone assist me in this please!
> > Many thanks/sgl
> >

 
Reply With Quote
 
Sam Wilson
Guest
Posts: n/a
 
      3rd Jan 2008
Ok, try this:


Sub demo()

Dim d, e As Date
d = "01/01/08 12:00:00"
e = "21/11/08 09:30:00"

Dim i As Integer

With Range("a1")
Do Until d > DateAdd("d", 15, e)
.Offset(i, 0).Value = d
.Offset(i, 1).Value = DateAdd("d", 15, d)
d = DateAdd("d", 15, d)
i = i + 1
Loop
End With

End Sub

"sgl" wrote:

> Hi Sam,
>
> Thanks for your quick response. I need to develop a VBA code as this is part
> of a much larger project that needs substantial automation for the users.
> Thanks anyway./sgl
>
>
> "Sam Wilson" wrote:
>
> > Hi,
> >
> > I don't think you really need any VBA for this if it's just a one-off. Why
> > don't you just put "01/01/08 12:00:00" in cell A2, and then put the formula
> > '=A2+15' in A3 and drag it down as far as you want etc?
> >
> > Sam
> >
> > "sgl" wrote:
> >
> > > Hi All,
> > >
> > > I have the following range of dates/times
> > >
> > > Start Date 1 Jan 08 12:00 hrs
> > > End Date 21 Nov 08 09:30 hrs
> > > Increment by 15 days
> > >
> > > Need to develop a VBA routine that builds a two column series as follows
> > > Col A ColB
> > > StartDate StartDate + Increment
> > > StartDate + Increment StartDate + Increment + Increment
> > > etc
> > > to EndDate
> > >
> > > Calculating the total time between dates in each row should give you a total
> > > time between SatrtDate and EndDate of 324.8958333 Days. As validation I will
> > > need to calcualte the total time between dates in each Row
> > > Can anyone assist me in this please!
> > > Many thanks/sgl
> > >

 
Reply With Quote
 
sgl
Guest
Posts: n/a
 
      4th Jan 2008
Sam Hi,
Thanks for your assistance which helped move forward. I tinkered a little
with your suggestion and have come up with the following.

Sub demo()

Dim d As Date, e As Date
d = "01/01/08 12:00"
e = "21/11/08 09:30"

Dim i As Integer

With Range("a1")
Do Until d > DateAdd("d", 0, e) 'this ensures you do not overun the
dates of 21/11/08
.Offset(i, 0).Value = d
If DateAdd("d", 15, d) > e Then
.Offset(i, 1).Value = e
Else
.Offset(i, 1) = DateAdd("d", 15, d)
End If
d = DateAdd("d", 15, d)
i = i + 1
Loop
End With

End Sub

This ensures that the last date (e) stops on 21 Nov 08 09:30 hrs which is
what I wanted to get to. Thanks for introducing me to the DateAdd VBA
function. Need to refresh myself on the VBA functions!

Thanks again/sgl

"Sam Wilson" wrote:

> Ok, try this:
>
>
> Sub demo()
>
> Dim d, e As Date
> d = "01/01/08 12:00:00"
> e = "21/11/08 09:30:00"
>
> Dim i As Integer
>
> With Range("a1")
> Do Until d > DateAdd("d", 15, e)
> .Offset(i, 0).Value = d
> .Offset(i, 1).Value = DateAdd("d", 15, d)
> d = DateAdd("d", 15, d)
> i = i + 1
> Loop
> End With
>
> End Sub
>
> "sgl" wrote:
>
> > Hi Sam,
> >
> > Thanks for your quick response. I need to develop a VBA code as this is part
> > of a much larger project that needs substantial automation for the users.
> > Thanks anyway./sgl
> >
> >
> > "Sam Wilson" wrote:
> >
> > > Hi,
> > >
> > > I don't think you really need any VBA for this if it's just a one-off. Why
> > > don't you just put "01/01/08 12:00:00" in cell A2, and then put the formula
> > > '=A2+15' in A3 and drag it down as far as you want etc?
> > >
> > > Sam
> > >
> > > "sgl" wrote:
> > >
> > > > Hi All,
> > > >
> > > > I have the following range of dates/times
> > > >
> > > > Start Date 1 Jan 08 12:00 hrs
> > > > End Date 21 Nov 08 09:30 hrs
> > > > Increment by 15 days
> > > >
> > > > Need to develop a VBA routine that builds a two column series as follows
> > > > Col A ColB
> > > > StartDate StartDate + Increment
> > > > StartDate + Increment StartDate + Increment + Increment
> > > > etc
> > > > to EndDate
> > > >
> > > > Calculating the total time between dates in each row should give you a total
> > > > time between SatrtDate and EndDate of 324.8958333 Days. As validation I will
> > > > need to calcualte the total time between dates in each Row
> > > > Can anyone assist me in this please!
> > > > Many thanks/sgl
> > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Next Build Shall be RTM guys not any other builds unless MS decides to do one more build because of bugs before RTM RC2 build 5477 is the last build before RTM Drew Windows Vista General Discussion 8 13th Oct 2006 12:41 AM
I meant RC2 Build 5744 is the last build unless ms find more bugs before the RTM build and gold version there only make another build if there more bugs and not ready for RTM Drew Windows Vista General Discussion 4 12th Oct 2006 02:17 PM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Storage Devices 2 4th Dec 2005 11:46 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI code_fu Anti-Virus 2 2nd Oct 2004 09:32 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI code_fu Windows XP Basics 0 2nd Oct 2004 05:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:22 PM.