Counting a number up when a worksheet is opened

  • Thread starter Thread starter Wendy
  • Start date Start date
W

Wendy

An example would be using it for invoices, you want the
invoice number to go up by one evertime you open that
worksheet.
Can this be done with a function?
 
Hi Wendy

a function won't do. You have to use VBA. Place the following code in
the workbook module
Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Range("A1").Value = Range("A1") + 1
End Sub

This will increase cell A1 on sheet 'Sheet1' by one each time you open
the workbook
HTH
Frank
 
Thanks Frank I did that but it's not working, could you
walk me thru putting it in the module? It seems to
recognize there's a macro to run, I enable it. But
nothing happens.

Thanks for your help.
 
Hi Wendy,
1. Open your workbook
2. Rightclick on the Excel symbol left to the menu entry 'File'
3. Select 'Code' in the context menu
4. Paste the code in the VBA editor
5. close the editor and save your workbook

HTH
Frank
 
Back
Top