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
| Sub Demo()
Application.ScreenUpdating = False
With Feuil1
With .Cells(1).CurrentRegion.Columns
C& = .Count + 2
.Item(6).AdvancedFilter xlFilterCopy, , .Parent.Cells(C), True
End With
With .Cells(C).CurrentRegion
VA = .Value
For R& = 2 To UBound(VA)
VA(R, 1) = Split(VA(R, 1), " - ")(1)
If Len(VA(R, 1)) > 31 Then VA(R, 1) = Left(VA(R, 1), 30) & "
"
Next
With .Resize(, 2)
.Columns(2).Value = VA
.Sort .Cells(2), xlAscending, Header:=xlYes
VA = .Value
End With
End With
For R = 2 To UBound(VA)
.Cells(2, C).Value = VA(R, 1)
With Worksheets
If Evaluate("ISREF('" & Replace(VA(R, 2), "'", "''") & "'!A1)") Then _
.Item(VA(R, 2)).UsedRange.Clear Else .Add(, .Item(.Count)).Name = VA(R, 2)
End With
.Cells(1).CurrentRegion.AdvancedFilter xlFilterCopy, .Cells(C).Resize(2), _
Worksheets(VA(R, 2)).Cells(1)
Next
.Cells(C).CurrentRegion.Clear
End With
Application.ScreenUpdating = True
End Sub |
Partager