How to replace numbers in sequence without sorting?

  • Thread starter Thread starter geniusideas
  • Start date Start date
G

geniusideas

Hi,

I need to replace those numbers duplicate so that it follow in
sequence for example:

In Column A I have these number
2,1,5,3,3,6,8,8 (Before)
2,1,5,3,4,6,8,9 (after)
Anyone got idea how to do it with macro?
Please.Thanks
 
See if this suit your needs:

Sub SequenseFill()
Col = "A"
FirstRow = 1
LastRow = Cells(FirstRow, Col).End(xlDown).Row
For r = FirstRow + 1 To LastRow
If Cells(r - 1, Col) = Cells(r, Col) Then
Cells(r, Col) = Cells(r, Col) + 1
End If
Next
End Sub

Regards,
Per
 
Back
Top