1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Sub regroup()
Application.ScreenUpdating = False
Dim F1 As Worksheet
Dim f2 As Worksheet
Dim Dercol As Long
Set F1 = Sheets("Base")
Set f2 = Sheets("Resultat")
f2.Cells.ClearContents
Dim i As Long
Set d = CreateObject("Scripting.Dictionary")
'**********************************************************
TblBD = F1.Range("A1:A" & F1.Range("A" & Rows.Count).End(xlUp).Row)
MsgBox UBound(TblBD)
For i = 1 To UBound(TblBD)
If IsNumeric(Right(TblBD(i, 1), 4)) And Not IsNumeric(Left(TblBD(i, 1), 2)) Then
If Not IsDate(TblBD(i - 1, 1)) Then
clé = TblBD(i - 1, 1) & "|" & TblBD(i, 1)
Else
clé = " "" " & "|" & TblBD(i, 1)
End If
End If
On Error Resume Next
If IsDate(TblBD(i + 1, 1)) Then d(clé) = d(clé) & "|" & Format(TblBD(i + 1, 1), "m/d/yyyy") 'CDate(TblBD(i + 1, 1))
Next i
f2.Range("A1").Resize(d.Count) = Application.Transpose(d.keys)
f2.Range("C1").Resize(d.Count) = Application.Transpose(d.items)
Application.DisplayAlerts = False
f2.Range("A1").Resize(d.Count).TextToColumns Other:=1, OtherChar:="|"
f2.Range("C1").Resize(d.Count).TextToColumns Other:=1, OtherChar:="|"
f2.Columns("C:C").Delete Shift:=xlToLeft
Application.ScreenUpdating = True
End Sub |
Partager