Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Increment number on command

Arran,

Try the macro below.

HTH,
Bernie
MS Excel MVP

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) & myVal + 5
ActiveCell.Offset(0, 1).Select
Exit Sub
notValue:
Resume TryNext:
TryNext:
Next myRow

End Sub


"Arran" wrote in message
...
Can any one help me out with some code that will start by looking back up the
column from the point of the active cell, find the last occurance of a Ref#,
increase it by 5, place the result in the active cell and finish by moving
one cell to the right.
Few points.
1) Ref# prefixed with maybe 1,2 or 3 letters but always followed by a 4
digit number, 0001 - 9999.
2)There will also be blank cells and ones containing just text in the column
3)Will run the code from a Command button on the Sheet

Any help gratefully received
Arran



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
Increment invoice number suzi_75 Excel Worksheet Functions 1 October 21st 09 12:12 PM
increment number by code nowfal[_16_] Excel Programming 3 July 19th 05 03:58 AM
How to increment number using vb script Lillian Excel Programming 4 December 5th 04 02:00 AM
Increment an Invoice number Gwyneth Excel Worksheet Functions 1 November 14th 04 01:42 PM
Increment number by 1 Joe Derr Excel Programming 5 May 16th 04 08:28 PM


All times are GMT +1. The time now is 11:39 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"