Macro for autonumbering

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Hi guys,

I'm designing a macro -even not being a macro expert- to process some
different files. In these files, I've some data in column B.

I want to make an autonumbering in column A (from cell A2 and below)
which reaches the same row that the data in column B. Both in column A
and B I have headers, that's the reason why I want to start from cell
A2. The number incrementation must be in one by one (1,2,3 and so).

For example, headers are in A "Number" and in B "Item". If B column
reaches cell B152, I want that A column reaches cell A152, and in A152
must be the number 151.

In other file, if B column reaches cell B347, I want that A column
reaches cell A347, and in A347 must be the number 346.

Do you have any idea about how I can do this?

Thank you very much.

and Merry Christmas and Happy New Year!
 
Sub numberrowsbynextcolumn()
mc = 2 'col B
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row
Cells(i, mc - 1) = i - 1
Next i
End Sub
 
Glad to help and Merry Xmas to all

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Excellent! Thank you very much for your fast answer and Merry
Christmas!
 
Back
Top