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 Test()
Dim F1 As Worksheet
Dim F2 As Worksheet
Set F1 = Sheets("Feuil1")
Set F2 = Sheets("Feuil2")
F2.Cells.ClearContents
F2.Cells(2, 1) = "titre1"
F2.Cells(2, 3) = "titre2"
F2.Cells(2, 3) = "titre3"
Dim derlig As Long
Dim lig As Long
Application.ScreenUpdating = False
derlig = F1.Range("B" & Rows.Count).End(xlUp).Row
For L = 2 To derlig
If Left(F1.Cells(L, 2), 3) = "AAA" Then
lig = F2.Range("A" & Rows.Count).End(xlUp).Row + 1
F1.Cells(L, 2).Copy
F2.Cells(lig, 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ElseIf Left(F1.Cells(L, 2), 3) = "BBB" Then
lig = F2.Range("B" & Rows.Count).End(xlUp).Row + 1
F1.Cells(L, 2).Copy
F2.Cells(lig, 2).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ElseIf Left(F1.Cells(L, 2), 3) = "CCC" Then
lig = F2.Range("C" & Rows.Count).End(xlUp).Row + 1
F1.Cells(L, 2).Copy
F2.Cells(lig, 3).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
Next L
Application.ScreenUpdating = True
End Sub |
Partager