Formula to add a number

  • Thread starter Thread starter Debbie
  • Start date Start date
D

Debbie

Can someone give me a formula so that I can have a number added automatically
to a cell each time I open a report.

The number is 10-200-1 and each time I open the report I want it to
automatically populate the fiield with the next number 10-200-2, 10-200-3 and
so on.

Thanks in advavnce for your help,
Deborah
 
When you say open a report I have assumed you mean open a workbook if so try
this

Private Sub Workbook_Open()
Sheets("Sheet1").Select 'Change to suit
oldnum = Left(Range("A1").Value, 7)
x = 1 + Val(Right(Range("A1").Value, Len(Range("A1").Value) - 7))
Range("A1").Value = oldnum & x
End Sub


Mike
 
By "open the report" , do you mean open the workbook? If so, and assuming
that the number is in Sheet1!A1 do the following.

1. Enter the initial number in the cell as a number value (no dashes) and
give it a custom format of "00-000-00".

2. Then put this code in the ThisWorkbook code module:

Private Sub Workbook_Open()
With Sheet1.Range("A1")
.Value = .Value + 1
End With
End Sub
 

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