View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GregR GregR is offline
external usenet poster
 
Posts: 246
Default How do you add 1 to an invoice number in Excel. Formula for this?

Bob, this is what I have in the ThisWorkbook code module:

Evaluate(ThisWorkbook).Names("UniqueId").RefersTo ("Inv")
Private Sub Workbook_Open()
GetId
End Sub
Private Sub GetId()

Dim myId As Long

myId = 1 ' in case it doesn't already exist
On Error Resume Next
myId = Evaluate(ThisWorkbook.Names("UniqueId").RefersTo) + 1
ThisWorkbook.Names.Add Name:="UniqueId", RefersTo:="=" & myId

End Sub

I have named "F4" with "Inv". I am sure I missed something, but not
sure what? TIA

Greg