View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
okrob okrob is offline
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