ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add 1 to a number each time you print (https://www.excelbanter.com/excel-programming/364284-add-1-number-each-time-you-print.html)

Jason1[_2_]

Add 1 to a number each time you print
 

I have a form that I have created that has a Shipper # in the top right
hand corner, each time someone prints the page I need this to
automatically add 1 to the number. People on this website have helped
me out numerous times, and I know you will be able to help me out with
this..


--
Jason1
------------------------------------------------------------------------
Jason1's Profile: http://www.excelforum.com/member.php...fo&userid=8352
View this thread: http://www.excelforum.com/showthread...hreadid=551968


kassie

Add 1 to a number each time you print
 
http://www.mcgimpsey.com/excel/udfs/sequentialnums.html

"Jason1" wrote:


I have a form that I have created that has a Shipper # in the top right
hand corner, each time someone prints the page I need this to
automatically add 1 to the number. People on this website have helped
me out numerous times, and I know you will be able to help me out with
this..


--
Jason1
------------------------------------------------------------------------
Jason1's Profile: http://www.excelforum.com/member.php...fo&userid=8352
View this thread: http://www.excelforum.com/showthread...hreadid=551968



Jim Thomlinson

Add 1 to a number each time you print
 
Add the following code to ThisWorkbook (Right click the excel icon next to
file on the menu and select view code). You will need to change the sheet
name and the range being updated (A1). This code should work for you so long
as you are not doing print previews (which will also fire off this code)...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
if activesheet.name = "Sheet1" then _
activesheet.range("A1").value = activesheet.range("A1").value + 1
End Sub
--
HTH...

Jim Thomlinson


"Jason1" wrote:


I have a form that I have created that has a Shipper # in the top right
hand corner, each time someone prints the page I need this to
automatically add 1 to the number. People on this website have helped
me out numerous times, and I know you will be able to help me out with
this..


--
Jason1
------------------------------------------------------------------------
Jason1's Profile: http://www.excelforum.com/member.php...fo&userid=8352
View this thread: http://www.excelforum.com/showthread...hreadid=551968



Johnny[_10_]

Add 1 to a number each time you print
 
Maybe something like this:

(air code)

This should be in the ThisWorkbook class module in the editor:

Private Sub Workbook_BeforePrint(Cancel as Boolean)
Dim r as Range

'Set up reference to range
Set r = Range("YourCellHere")

With r
'Add one to the value already in the cell
.Cells(1,1).Value = .Cells(1,1).Value + 1
End with

'Clean up
Set r = Nothing
End Sub

HTH,
Johnny


Jason1[_3_]

Add 1 to a number each time you print
 

You all are the best..Thanks for everything, worked like a charm...


--
Jason1
------------------------------------------------------------------------
Jason1's Profile: http://www.excelforum.com/member.php...fo&userid=8352
View this thread: http://www.excelforum.com/showthread...hreadid=551968



All times are GMT +1. The time now is 01:42 PM.

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