View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Macro to autonumber cells

Jim

one way:

Sub AutoNumberCells()

Dim iCount As Integer
Dim BaseNumber As String
Dim cell As Range

iCount = 1
BaseNumber = Selection(1).Offset(-1, 0)

For Each cell In Selection
cell.Value = BaseNumber & "." & iCount
iCount = iCount + 1
Next 'cell

End Sub

Regards

Trevor


"JimG" wrote in message
...
I have an excel sheet where I want to be able to select a range of cells in
a
column and have excel automatically number them based on the value in a
previous row.

e.g. if A1 = 1, and I select A2 through A4, I want to be able to
automatically number A2 to A4 as 1.1, 1.2, 1.3. The idea is that if I
then
insert a new row between A2 and A3, I could select the new A2 through A5
and
renumber as 1.1 through 1.4.

I hope I've made it clear what I am after.