Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 262
Default Macro to print series of dates

Good afternoon

I have a worksheet which when printed needs a date in cell G1. That's the
easy part...

What I am trying to achieve is that the user inputs a start date and an end
date and for each sheet printed the first has the start date in G1, the
second has G1+1 through to the end date excluding Saturdays and Sundays and
ideally other dates on an exception list e.g. Bank Holidays.

Hopefully that is clear but I am at a complete loss as to where to even
start so would really appreciate some help.

Many thanks

Kewa




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macro to print series of dates

Kewa,

List your holidays somewhere on your sheet, and name the range "Holidays" (without the quotes).

Then insert a userform into your project, and put two datetimepickers (named DTPicker1 and
DTPicker2 - You will need a reference to MS Windows Common Controls to use the datetimepickers) onto
the form, with a commandbutton. Use labels to show that the first DTPicker is the Start Date and the
second is the End Data, then use this code for the commandbutton (replace "SheetName" with the
actual sheet name):

Private Sub CommandButton1_Click()
Dim myDate As Date
Dim myStartDate As Date
Dim myEndDate As Date
myStartDate = Me.DTPicker1.Value
myEndDate = Me.DTPicker2.Value
For myDate = myStartDate To myEndDate
If Format(myDate, "dddd") < "Saturday" And _
Format(myDate, "dddd") < "Sunday" And _
IsError(Application.Match(CLng(myDate), Range("Holidays"), False)) Then
Worksheets("SheetName").Range("G1").Value = myDate
Worksheets("SheetName").PrintOut
End If
Next myDate
End Sub


Then use this macro to show the userform:

Sub PickDatesToPrint()
Load UserForm1
UserForm1.Show
End Sub

HTH,
Bernie
MS Excel MVP


"Keith" wrote in message
...
Good afternoon

I have a worksheet which when printed needs a date in cell G1. That's the
easy part...

What I am trying to achieve is that the user inputs a start date and an end
date and for each sheet printed the first has the start date in G1, the
second has G1+1 through to the end date excluding Saturdays and Sundays and
ideally other dates on an exception list e.g. Bank Holidays.

Hopefully that is clear but I am at a complete loss as to where to even
start so would really appreciate some help.

Many thanks

Kewa






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
Fill series dates JR Hester Excel Discussion (Misc queries) 0 October 15th 09 05:54 PM
Need to create a series of dates across a row Equinor Excel Discussion (Misc queries) 4 January 26th 09 05:32 PM
Fill Series Dates: not letting me change the series from year to m Mike Excel Discussion (Misc queries) 1 January 24th 08 05:08 PM
Automating a series of dates for two columns? valholler Excel Worksheet Functions 0 September 28th 06 09:17 PM
HOW DO I SET UP A SERIES OF DATES IN EXCEL? tpapd754 Excel Discussion (Misc queries) 1 February 3rd 05 11:39 PM


All times are GMT +1. The time now is 06:59 PM.

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

About Us

"It's about Microsoft Excel"