How do I get a number to change after each print?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to set of a shipping form. I want to know if there is a format in
which I can have a number on the top of my page and it change after every
print I print. I don't know if I am explaining this well so I will give an
example:
No. 26786 for the first print and when I close it and open it again I want
the number to change to 26787 and so on. I don't want to keep using the same
number it will get hard to track pacakges. I believe this is possible I just
don't know how....any help would be greatly appreciated!!! :)
Thanks,
Jennifer - Houston, TX
 
Jennifer

You can use a Workbook_BeforePrint() event. To implement right click on the
Excel icon at the top left of the workbook (not the application icon) and
select view code. Paste it in the resulting window

You will need to change the worksheet name from ShippingData to the actual
one and the cell from A1 to whatever it is (in two places). Now each time
you *before* you print, that number will increment by 1

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "ShippingData" Then
ActiveSheet.Range("A1").Value = ActiveSheet.Range("A1").Value + 1
End If
End Sub

--

HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
web: www.nickhodge.co.uk
blog (non tech): www.nickhodge.co.uk/blog
 
Thanks that helped so fast!! Next time I will post my question before I spend
hours trying to figure it out on my own!! Thanks again!!!
 
Thank you for a quick response!! That worked!!

Nick Hodge said:
Jennifer

You can use a Workbook_BeforePrint() event. To implement right click on the
Excel icon at the top left of the workbook (not the application icon) and
select view code. Paste it in the resulting window

You will need to change the worksheet name from ShippingData to the actual
one and the cell from A1 to whatever it is (in two places). Now each time
you *before* you print, that number will increment by 1

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "ShippingData" Then
ActiveSheet.Range("A1").Value = ActiveSheet.Range("A1").Value + 1
End If
End Sub

--

HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
web: www.nickhodge.co.uk
blog (non tech): www.nickhodge.co.uk/blog
 
Sorry I spoke to soon...I typed the code in just as you said but it still
doesn't change the number. I still don't know what I am doing wrong? Do you
have any ideas. Thanks Jennifer
 
Back
Top