Excel / after print +1 [Solved/Closed]

Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,
My name is David (form Slovakia)!

I would like to ask you for help with the folowing situation to solve:
I need to prepear one document which will be used as some kind of dynamical odette label.
You can choose delivery note number, customer reference, autmoaticaly adds the description and so on...

THAT I HAVE DONE! So than, you can ask, where is the problem? Exactly the problem is that there should be also one unique serial number consisting of last two digits of current year, weekday, and weeknum ... to this moment everything is still ok but to this formula YYDDWW should be added also one aspect and it is the number of packaging of the day.

The problem is in the way how this "packaging of the day" - value should work. If somebody come to the computer and select some references, and set the informations to be printed... the "packaging of the day" - value wont change ... only after print.

Lets imagine that we have a this "packaging of the day" - value of 3 digits for ex.: 001 ...
In the document thatn it looks like this: the mentioned YYDDWW+"packaging of the day" - value so finaly it would looks like this : YYDDWW+001.

When we print the document than then condition should make YYDDWW+002

So after every printing the "packaging of the day" - value will rise by one. Is it possible to do?
Sure every printing after closing document will require saving to keep this serial number unique for the next opening.

Thanks for read and help.

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
I think you need some thing like this

Private Sub Workbook_BeforePrint(Cancel As Boolean)

Application.EnableEvents = False

' Cancel your actual print request
Cancel = True

'HERE ADD THE CODE FOR PRINTING THRU MACRO

'HERE INCREASE THE PRINT COUNTER BY 1

Application.EnableEvents = True


End Sub


of course when you close the sheet, make sure you save the workbook to store the changed value
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!