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 34 35 36 37 38 39 40 41 42 43 44
| Sub colonne_ABC()
Application.Calculation = xlManual 'Arrête certains calculs automatiques
Application.ScreenUpdating = False 'fige l'affichage pendant la macro pour l'accélérer
Range(Worksheets("CODE").Range("C5"), Worksheets("CODE").Range("C5").End(xlDown)).Clear 'efface la colonne depuis C5 jusqu'à la denriere cellule non vide
Dim temps_debut As Single
Dim duree As Single
Dim cellule1 As String
Dim a1 As Integer
Dim a2 As Integer
Dim position1 As String
Dim position3 As String
Dim position2 As String
Dim rg As Range
temps_debut = Timer 'pour chrono de la macro
Worksheets("CODE").Range("$B$3").End(xlDown).Select 'calcul le nombre de cellules consécutives non vides en colonne B depuis B3 jusqu'à la dernière cellule non vide
a1 = 1 'initialisation des compteurs
a2 = 1 'initialisation des compteurs
position1 = "$A$" & CStr(a1 + 4)
position3 = "$C$" & CStr(a2 + 4)
position2 = "$B$4:$B$" & CStr(ActiveCell.Row)
cellule1 = Worksheets("CODE").Range(position1).Value
Do While cellule1 <> Empty
Set rg = Worksheets("CODE").Range(position2).Find(cellule1, LookIn:=xlValues, MatchCase:=True)
If rg Is Nothing Then
Worksheets("CODE").Range(position3).Value = Worksheets("CODE").Range(position1).Value
a2 = a2 + 1
position3 = "$C$" & CStr(a2 + 4)
End If
a1 = a1 + 1
position1 = "$A$" & CStr(a1 + 4)
cellule1 = Worksheets("CODE").Range(position1).Value
Loop
duree = Timer - temps_debut 'calcul de la durée de la macro
Range("A1").Value = duree 'affichage du temps de calcul de la macro en cellule A1
Application.Calculation = xlAutomatic 'Réactive les calculs
End Sub |
Partager