Incrementing last digit in a custom serial number

cherrydee

New Member
Joined
Jan 1, 2017
Messages
13
Hi, i am trying to increment the last digit of a custom field. An example is 2018-08-001. The code i am using is left(a1,10) & 1 + right(a1,1)
I am having issues when it reaches 2018-08-009. It becomes 0010. Also probable future problem is whenb it reaches 2018-08-999.
Any help is appreciated. Thank you!
 
This works like a charm! :) Tho i removed the for loop since i put the nextvalue in msgbox and it won't stop. Lol. Anyway, not sure what the for loop is for.
Glad it works for you, just added the for loop to demonstrate the output.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi, your code works great! But how can i adjust it when it reaches thousands like 2018-08-1000? Cause I'm not really sure how long the records would be.
Once the last 3 digits reach 999, the roll-over turns the 999 to 000 and adds 1 to the two digit number. So, once it reached this...

2018-08-999

then next number would be this...

2018-09-000

What I wasn't sure of is if 000 would be the correct roll-over number or should 000 be skipped and 001 be the number following 999 (the reason I wondered about this is because apparently, your starting number is 2018-08-001, not 2018-08-000).
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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