Hello VBA cannons
I have a report in cell A1 the date
I want to print a number of reports that each time the date will be increased by a day.
Or a second option to write from date to date for example: 1/8/22-15/8/22
And I will print everything and each printing will cost a day?
Thanks
Hi,
You want to print to active printer or to pdf?
active printer
Simply use this code in a standard vba module:
Sub PrintSheet()
ActiveSheet.PrintOut
ActiveSheet.Range("A1").Value=ActiveSheet.Range("A1").Value+1
End Sub
In the sheet you want to print, insert any shape, then right click that shape, click on Assign Macros and assign the PrintSheet macro you just added.
Not good!
I want to print automatically with just one click from 1/8/22-15/8/22 a total of 15 pages.
Thanks
Could you use that code in a For Each loop?
dim ws as Worksheet
for each ws in thisworkbook
ws.PrintOut
ws.Range("A1").Value=ws.Range("A1").Value+1
next ws
and put it in the workbook BeforePrint event.
Please if possible see the file and fix it. Thanks
Anyone want to help?
please
try this one:
Sub PrintSheet()
Dim i As Long
For i = 1 To 14
ActiveSheet.PrintOut
ActiveSheet.Range("A1").Value = ActiveSheet.Range("A1").Value + 1
Next i
End Sub
Champion
Hi I don't understand why it prints me half a page wide?
can i help please
You have to set the print area, the code does not do that, just prints what you have set.
You can view the print area from ribbon: View>Page Break Preview, you have that icon next to the page zoom slider on bottom left. Drag the blue page breaks to organize them.