PDA

View Full Version : [SOLVED] AUTOMATIC ROW NUMBER GENERATOR



krishnaa_kum
10-16-2014, 06:31 AM
HI,

Does anyone knows how to generate automatic row number .
Example:
I have data from coloumn A till coloumn O. I would like to generate automatic row number in coloumn O only if the particular row is filled.
I tried using formula row() but it gives u row number for all the cells. I just want row number for active cells.

Thanks

ranman256
10-16-2014, 06:50 AM
adjust the macro as you need.



Sub RowNumbers()
Dim r As Long, i As Long, iTot As LongiTot = ActiveSheet.UsedRange.Rows
i = 1
Range("O2").Select 'column for row #
For r = 1 To iTot
If ActiveCell.Offset(0, 1).Value <> "" And ActiveCell.Offset(0, 3).Value <> "" Then
ActiveCell.Value = i
i = i + 1
End If

ActiveCell.Offset(1, 0).Select 'next row
Wend
End Sub

SamT
10-16-2014, 07:19 AM
O1 =IF(COUNTA(A1:N1) = 0,"",ROW(A1))

krishnaa_kum
10-16-2014, 07:29 AM
THANKS A LOT. ITS WORKING

SamT
10-16-2014, 08:37 AM
:thumb