ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do set a number so that it automatically changes (https://www.excelbanter.com/excel-worksheet-functions/37279-how-do-set-number-so-automatically-changes.html)

susan

how do set a number so that it automatically changes
 
I need to generate a running/consecutive number that will change everytime I
print of the worksheet in cell A1. I cant remember how to do it!!!
Thanks

Bob Phillips

One simple way

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("A1").Value = Range("A1").Value + 1
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"susan" wrote in message
...
I need to generate a running/consecutive number that will change everytime

I
print of the worksheet in cell A1. I cant remember how to do it!!!
Thanks





All times are GMT +1. The time now is 04:29 AM.

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