View Single Post
 
Old 05-03-2016, 09:25 AM
carlos_cs carlos_cs is offline Windows 10 Office 2013
Novice
 
Join Date: May 2016
Posts: 6
carlos_cs is on a distinguished road
Default

I managed to get the answer. I'll post here just in case somebody has the same problem!

Sub timeline()
Dim i As Long
Dim ws As Worksheet
Dim ts As Worksheet
Set ws = Sheets("Sheet15") 'Change to your Output Sheet
Set ts = Sheets("Sheet14") 'Change to your data sheet
With ws
i = ts.Range("A" & ts.Rows.Count).End(xlUp).Row
ts.Range("A1:C" & i).Copy .Range("A1")
.Range("A1:C" & i).Sort Key1:=.Range("A2"), Order1:=xlAscending, _
key2:=.Range("C2"), Order2:=xlAscending, _
Header:=xlYes
Do Until i = 2
If .Cells(i, 1).Value2 = .Cells(i - 1, 1).Value2 Or .Cells(i, 1).Value2 = .Cells(i - 1, 1).Value2 + 1 Then
i = i - 1
Else
.Rows(i).Insert
.Cells(i, 1).Value = .Cells(i + 1, 1).Value2 - 1
.Cells(i, 2).Value = 0#
.Cells(i, 3).Value = "--"
End If
Loop
End With
End Sub
Reply With Quote