Forum

Notifications
Clear all

print

12 Posts
3 Users
0 Reactions
66 Views
(@oferm)
Posts: 7
Active Member
Topic starter
 

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

 
Posted : 05/08/2022 5:26 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi,

You want to  print  to active printer or to pdf?

 
Posted : 10/08/2022 12:23 am
(@oferm)
Posts: 7
Active Member
Topic starter
 

active printer

 
Posted : 10/08/2022 3:29 pm
(@catalinb)
Posts: 1937
Member Admin
 

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.

 
Posted : 11/08/2022 1:15 am
(@oferm)
Posts: 7
Active Member
Topic starter
 

Not good!

I want to print automatically with just one click from 1/8/22-15/8/22 a total of 15 pages.

Thanks

Confused

 
Posted : 11/08/2022 5:28 pm
(@jstewart)
Posts: 216
Estimable Member
 

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. 

 
Posted : 11/08/2022 7:50 pm
(@oferm)
Posts: 7
Active Member
Topic starter
 

Please if possible see the file and fix it. Thanks

 
Posted : 12/08/2022 9:48 am
(@oferm)
Posts: 7
Active Member
Topic starter
 

Anyone want to help?

please

 
Posted : 16/08/2022 3:06 pm
(@catalinb)
Posts: 1937
Member Admin
 

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

 
Posted : 17/08/2022 1:23 am
(@oferm)
Posts: 7
Active Member
Topic starter
 

WinkWinkWinkWinkWinkWinkWinkWinkWink

Champion

 
Posted : 19/08/2022 10:03 am
(@oferm)
Posts: 7
Active Member
Topic starter
 

Hi I don't understand why it prints me half a page wide?

can i help please

 
Posted : 01/09/2022 3:14 pm
(@catalinb)
Posts: 1937
Member Admin
 

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.

 
Posted : 01/09/2022 11:32 pm
Share: