Increment number on command
Thanks for the alert Bernie. Guess I left out a line.
Anyway, to be just as helpful:
I tested it, and it worked.
What did you get if the reference value was rr0022
Yours returned rr27 - for me. My guess would be that wouldn't be
correct, so
Bernie's code did not work
for me: here is a working version: <g
Sub ArranSub()
Dim myRow As Long
Dim myValue As String
Dim myVal As Integer
For myRow = ActiveCell.Row To 1 Step -1
On Error GoTo notValue
myValue = Cells(myRow, ActiveCell.Column).Value
myVal = CInt(Right(myValue, 4))
ActiveCell.Value = Left(myValue, Len(myValue) - 4) _
& Format(myVal + 5, "0000")
ActiveCell.Offset(0, 1).Select
Exit Sub
notValue:
Resume TryNext:
TryNext:
Next myRow
End Sub
Lightly tested by me. Bernie's will work with a straight 4 digit number
while mine will look only for prefixed 4 digit numbers, so his may be more
desirable if that is a requirement.
--
Regards,
Tom Ogilvy
|