LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default How to autoincrement with Leading Zeroes?


I have a string variable: x = "item000"

I would like to code to autogenerate a code such that when the code gets
executed, I increment the item by 1 from its previous value. (so, I see
values like item000, item001, item 002....item010, item 011...)
How do I accomplish this?

The code I have thus far which doesn't work is below:

rightstring = Right(x,3)
lefstring = left(x,len(x)-len(rightstring))
autonum = cstr(Right("000" & cint(rightstring) + 1, 3))
msgbox(autonum)
__________________________________________

Any ideas how to get this done?




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Leading zeroes in ZIP field KateB Excel Discussion (Misc queries) 2 December 6th 06 12:44 AM
Sorry, leading zeroes again :-(( Argghhhh Excel Discussion (Misc queries) 7 November 13th 06 10:26 PM
Leading Zeroes Melissa Excel Discussion (Misc queries) 3 October 11th 06 07:38 PM
Leading Zeroes Ken Excel Discussion (Misc queries) 1 October 7th 05 03:17 PM
CSV leading zeroes Tim_nol Excel Discussion (Misc queries) 2 December 28th 04 08:19 PM


All times are GMT +1. The time now is 02:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"