Counting a number up when a worksheet is opened

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?
 
F

Frank Kabel

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
 
W

Wendy

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.
 
F

Frank Kabel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top