Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
increment number by code
hi, I got a formula to increment the number ie. =OFFSET(A3,1,O)+1 but i am searching how to do by code so that no user can delete th formula recently i saw a code that is incrementing the number to the next line what i am looking for one number more than A4 . If A4 is 999 , A3 to show 1000 Below the code i saw in another thread, is it possible to alter th code and use for me . Any help is highly appreciated. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim newval As Long 'test if its in the table If Range("B1").End(xlDown).Address = Target.Address Then If Target.Offset(0, -1).Value = "" Then newval = Target.Offset(-1, -1).Value + 1 Do While WorksheetFunction.CountIf(Range("A:A"), newval) 0 newval = newval + 1 Loop Target.Offset(0, -1).Value = newval End If End If End Sub thanks and regards nowfa -- nowfa ----------------------------------------------------------------------- nowfal's Profile: http://www.excelforum.com/member.php...fo&userid=1000 View this thread: http://www.excelforum.com/showthread.php?threadid=38945 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Increment invoice number | Excel Worksheet Functions | |||
increment number by code | Excel Programming | |||
How to increment number using vb script | Excel Programming | |||
increment date code | Excel Programming | |||
Increment number by 1 | Excel Programming |