Use the Field Calculator to populate a field with ordered numbers


Instructions provided explain how to populate a field in a feature class or stand alone table (DBF, CSV, etc.) with ascending, or ordered values, using an initial value and a designated interval.

The content in this article pertains to ArcGIS versions 8.x and 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.


To calculate a field using consecutive or stepped values:

  1. In the attribute table, add a Long Integer type field. If calculating an existing field, make sure it is a Long Integer Type.
  2. Right-click the heading of the new field.
    1. Select Calculate Values (9.1 and previous) or Field Calculator (9.2 and later).
    2. Click Yes when asked whether or not to calculate outside an edit session.
  3. In the Field Calculator dialog box, check Advanced. Copy and paste the following code into the PreLogic VBA Script Code box:
Static rec As Long 
Dim lStart As Long 
Dim lInterval As Long 
Dim i As Integer 
Dim iStringLength As Integer 
Dim sID As String 
'set the variables below 
iStringLength = 7 
lStart = 1 
lInterval = 1 
sID = "" 
If (rec = 0) Then 
rec = lStart 
rec = rec + lInterval 
End If 
For i = 1 To iStringLength - Len(CStr(rec)) 
sID = sID & "0" 
Next i 
sID = sID & CStr(rec) 
  1. If necessary, set the values for the variables iStringLength, lStart, and lInterval where indicated. lStart is the first value; lInterval is the step interval. For example, to count by 10, set lStart = 10 and lInterval = 10.
  2. In the bottom input box of the Field Calculator dialog box, enter sID.
  3. Click OK in the Field Calculator dialog box.

Article ID:000008783

  • ArcMap 9 x
  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic