Excel

Auto Row Numbering

Ease of Use

Easy

Version tested with

2000, 2003 

Submitted by:

lucas

Description:

When you click any cell in a row, that row is numbered automatically in Column C 

Discussion:

If you are like me and use numbered rows a lot, you probably get tired of typing in each number. Put this script in the code for the sheet you wish to use and start your data in Column D. Each time you type in any cell, that row will be numbered in Column C. Easy to change which column gets numbered in the script. See comments in the code. Credit for the original code goes to Aaron Blood 

Code:

instructions for use

			

Put this code In the sheet module: Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Dim RowOffset As Long Dim IndexCol As String 'Set values RowOffset = 0 'Change the C to the column where you want the numbers to show IndexCol = "C" Intersect(ActiveCell.EntireRow, Columns(IndexCol)).Value = ActiveCell.Row + RowOffset End Sub

How to use:

  1. Right mouse click on the sheet tab for any sheet you wish to auto-number
  2. select "View Code"
  3. Paste the code above into the worksheet module and close the VBE
 

Test the code:

  1. Click on any cell of the sheet and your row will be numbered.
 

Sample File:

auto_number.zip 6.75KB 

Approved by mdmackillop


This entry has been viewed 438 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express