Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Padding with 0's overflow

This sub works to add 1 to an invoice #, complete with padding 0's,
but when I get to invoice # C99999, I hit an overflow error. Can I
make the formatting floating but with a minimum of 5 places?
Rob

Sub test()
Dim x As String
Dim y As Integer
Dim pref As String
x = Sheet1.[A1].Value
y = Evaluate(Mid(x, 2, Len(x) - 1))
y = y + 1
x = "C" & Format(y, "00000")
Sheet1.[A1].Value = x
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Padding with 0's overflow

The maximum integer is 32767. You can use the routine to generate
numbers from 32768-99999 if you Dim y as a Long

In article . com,
"okrob" wrote:

This sub works to add 1 to an invoice #, complete with padding 0's,
but when I get to invoice # C99999, I hit an overflow error. Can I
make the formatting floating but with a minimum of 5 places?
Rob

Sub test()
Dim x As String
Dim y As Integer
Dim pref As String
x = Sheet1.[A1].Value
y = Evaluate(Mid(x, 2, Len(x) - 1))
y = y + 1
x = "C" & Format(y, "00000")
Sheet1.[A1].Value = x
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Padding with 0's overflow

y = 99999
? Format(y, "#00000")
99999
y = 100000
? Format(y, "#00000")
100000
--
Regards,
Tom Ogilvy



"okrob" wrote:

This sub works to add 1 to an invoice #, complete with padding 0's,
but when I get to invoice # C99999, I hit an overflow error. Can I
make the formatting floating but with a minimum of 5 places?
Rob

Sub test()
Dim x As String
Dim y As Integer
Dim pref As String
x = Sheet1.[A1].Value
y = Evaluate(Mid(x, 2, Len(x) - 1))
y = y + 1
x = "C" & Format(y, "00000")
Sheet1.[A1].Value = x
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Padding with 0's overflow

On Mar 23, 1:19 pm, Tom Ogilvy
wrote:
JE was a bit more astute than me in recognizing the fact you were using an
integer rather than a long. Make sure you read his post.

--
Regards,
Tom Ogilvy



"okrob" wrote:
On Mar 23, 9:41 am, Tom Ogilvy
wrote:
y = 99999
? Format(y, "#00000")
99999
y = 100000
? Format(y, "#00000")
100000
--
Regards,
Tom Ogilvy


"okrob" wrote:
This sub works to add 1 to an invoice #, complete with padding 0's,
but when I get to invoice # C99999, I hit an overflow error. Can I
make the formatting floating but with a minimum of 5 places?
Rob


Sub test()
Dim x As String
Dim y As Integer
Dim pref As String
x = Sheet1.[A1].Value
y = Evaluate(Mid(x, 2, Len(x) - 1))
y = y + 1
x = "C" & Format(y, "00000")
Sheet1.[A1].Value = x
End Sub- Hide quoted text -


- Show quoted text -


Thanks once again Tom...- Hide quoted text -


- Show quoted text -


I did actually change it to long...

Reply
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
Cell padding Jennifer Excel Discussion (Misc queries) 1 December 3rd 09 10:37 PM
Padding and Concatenate Static Excel Discussion (Misc queries) 2 November 2nd 07 07:40 PM
padding ? vbastarter Excel Discussion (Misc queries) 2 March 7th 06 12:11 PM
Padding Numbers couger77 Excel Programming 14 December 30th 03 04:02 PM
Value padding in VBA raj Excel Programming 2 December 14th 03 09:51 PM


All times are GMT +1. The time now is 05:56 PM.

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

About Us

"It's about Microsoft Excel"