View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default How to replace numbers in sequence without sorting?

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

On 20 Jul., 15:48, geniusideas wrote:
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