Advancing A Number With The Push A Button

  • Thread starter Thread starter Minitman
  • Start date Start date
M

Minitman

Greeting,

I have an invoice that uses a button to advance the invoice number by
1. When I wrote it the numbers were just numbers, but since then a
letter has been added to the front of the number (was 17445 now
D-017445). My advancing code no longer works and I don't know why!

Here is the code:

Private Sub GetNextInv_Click()
Range("InvNoLast").Value = Range("InvNoLast").Value + 1
End Sub

Anyone have an idea on how to fix it?

Any help would be most appreciated.

TIA

-Minitman
 
Hi
one idea:
why not format the cell with the custom format:
"D-"000000

This way you still store the numbers but show the characters
 
It no loger works because D-017445 is text, not a string. Addition with
strings is not defined.

Try

Private Sub GetNextInv_Click()
Dim x As String
x = Range("A1").Value
Range("A1").Value = Left(x, 2) & Application.Text(CDbl(Mid(x, _
3, Len(x) - 2)) + 1, "000000")
End Sub

Jerry
 
Thank you Frank and Jerry,

One other problem, how would I modify this code to use a ScrollBar?

-Minitman
 
Why a scrollbar - do you want to advance or regress many numbers at a time?
 
No. But I have never used one and wanted to get a little experience
with them.
 

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