StacGuesses
New Member
- Joined
- Mar 27, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hello, I'm trying to make a macro to autoincrement my invoice number which is a combination of letters and numbers. I'd like the last number to increase by 1 every time I run the macro.
ex. ABC-2023-01
increasing to
ABC-2023-02
1) do I need to first identify my variable as a string? or is there another data type to use?
2) if I identify it as a string do I then convert to an integer or long data type?
Current code that doesn't work
Sub CreateNewInvoice()
Dim invno As String
invno = Range("C3")
Range("B9, B19:I18").ClearContents
MsgBox "Your next invoice number is" & invno + 1
Range("B9").Select
ThisWorkbook.Save
End Sub
Thanks to all those that can help.
ex. ABC-2023-01
increasing to
ABC-2023-02
1) do I need to first identify my variable as a string? or is there another data type to use?
2) if I identify it as a string do I then convert to an integer or long data type?
Current code that doesn't work
Sub CreateNewInvoice()
Dim invno As String
invno = Range("C3")
Range("B9, B19:I18").ClearContents
MsgBox "Your next invoice number is" & invno + 1
Range("B9").Select
ThisWorkbook.Save
End Sub
Thanks to all those that can help.