Overflow (Error 6) for Incremental Value

Rowane

New Member
Joined
Sep 25, 2015
Messages
15
Hi all

I am a newbie in this. I have copied a code to increase my delivery order value in Cell C5 which time i click a control button. Code is as follows:-

Dim num As Integer
Range("C5").Select
num = Range("C5").Value
num = num + 1
Range("C5").Value = num


End Sub

If the number of the C5 is 5 digits, no problem for the value to increase. But my DO number is eg. 1500983, I encountered "Overflow (Error 6)" message and when i clicked on "Debug", "num = Range("C5").Value" is highlighted.

I have no idea how to solve this issue. Would greatly appreciate if anyone could help me with this error.
 
Thank so much Robert...not sure if you are able to explain to me what the '4' stands for? and why there's a - 3?
I am trying to make sense out of it...:)
 
Upvote 0
are able to explain to me what the '4' stands for

It's the position the number in the string i.e. DO 123456 starts from. This is why I needed to know if there was a space or not.

and why there's a - 3

This makes the code pick up all digits from from the first three characters of the string (again this is why I needed to know if there was a space or not).

HTH

Robert
 
Upvote 0
Thanks soooooo much...really really appreciate it..actually i have few more questions but I guess I am asking too much for now...
Guess this code can help me alot in other forms..thanks for your time.
 
Upvote 0
You're welcome. Just start a new thread for any other question(s) you have.

Regards,

Robert
 
Upvote 0
Hi sorry to bother you cos I am using the code that you have given me in other forms, my Purchase Order.
My output should look like this - PO09-001/15 where PO09 is fixed and /15 is fixed. However when i run the macro, it turns out PO09-2/15 instead of PO09-002/15. Please help me correct the code. Thank you very much.

Please don't PM members asking for help as it defeats the purpose of having a public forum. Thanks.

That said, try this:

Code:
Range("C5").Value = "PO09-" & Format(Val(Mid(Range("C5"), 6, Len(Range("C5")) - 5)) + 1, "000") & "/15"

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,226,771
Messages
6,192,926
Members
453,767
Latest member
922aloose

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top