Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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 date code prodsched[_6_] Excel Programming 1 May 17th 04 08:29 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 10:40 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"