increasing a cell value on each use

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

Guest

I want to have a rolling total on 1 cell...such as an invoice number, each
time I open a worksheet. Is there a way to do this?
 
I think I'd do this with a Workbook_Open event.

Copy this to the "ThisWorkbook" code module and modify as necessary.

Private Sub Workbook_Open()
On Error Resume Next
Set myws = Nothing
Set myws = Worksheets("Sheet1") 'Modify
'Alternatively
Set myws = Sheet1 'Uses worksheet codename instead
On Error GoTo 0
If Not myws Is Nothing Then
myws.Range("A1").Value = myws.Range("A1").Value + 1 '<~~~modify
End If


End Sub

HTH,
Barb Reinhardt
 

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

Back
Top