ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Incrementing the date (https://www.excelbanter.com/excel-discussion-misc-queries/163934-incrementing-date.html)

mills08

Incrementing the date
 
I'm trying to print a daily register, with the date on the top, is it
possible to increment the date for every day of the month to save having to
change the date 30 odd times? I would like to print them off all in one go
without having to change the date several times.

Gord Dibben

Incrementing the date
 
You wish to print 30 copies in one print job with the date changing in each
copy?

Here is a revised version of code from Ron de Bruin's site

Sub PrintCopies_ActiveSheet_1()
Dim CopiesCount As Long
Dim CopieNumber As Long
Dim startdate As Date

CopiesCount = Application.InputBox("How many copies do you want", Type:=1)
startdate = InputBox("enter a starting date")

For CopieNumber = 1 To CopiesCount
With ActiveSheet
' This example print the number in cell A1
'.Range("A1").Value = Format(startdate - 1 + _
CopieNumber, "dddd mmmm dd ,yyyy")
'If you want the number in the header use this line
.PageSetup.CenterHeader = Format(startdate - 1 + _
CopieNumber, "dddd mmmm dd ,yyyy")
'Print the sheet
.PrintOut preview:=True 'for testing
' .PrintOut 'for printing
End With
Next CopieNumber
End Sub

No error-checking.

For original code from Ron see http://www.rondebruin.nl/print.htm#same


Gord Dibben MS Excel MVP

On Mon, 29 Oct 2007 09:11:03 -0700, mills08
wrote:

I'm trying to print a daily register, with the date on the top, is it
possible to increment the date for every day of the month to save having to
change the date 30 odd times? I would like to print them off all in one go
without having to change the date several times.




All times are GMT +1. The time now is 11:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com