Message d'erreur dans un code
Bonjour à tous,
J'ai mis en place ce code qui est censé me trier les notes de mon tableau de la plus grande à la plus petite.
Mais voilà, j'ai changé d'ordinateur, je suis sur la version Excel 2003 et un message d'erreur apparaît sur la ligne en rouge de mon code. J'ai la même version d'Excel sur les 2 postes.
Le message d'erreur est : "Erreur d'exécution 438 - Propriétée ou méthode non gérée par cet objet".
Pouvez m'éclairer à ce sujet et m'aider à trouver la solution s'il vous plait ?
Je vous en remercie par avance
Code:
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 45 46 47 48 49
|
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastLig As Long, NewLig As Long, Nb As Long
If Target.Address = "$A$2" Then
Union(Range("A4:H" & Rows.Count), Range("J4:K" & Rows.Count), Range("M4:M" & Rows.Count)).ClearContents
If Target <> "" Then
With Sheets("Général")
.Range("A3").AutoFilter
LastLig = .Cells(Rows.Count, "G").End(xlUp).Row
If LastLig < 4 Then
If .Range("A3").AutoFilter = True Then .Range("A3").AutoFilter
Exit Sub
End If
With .Range("A3:N" & LastLig)
.AutoFilter
.AutoFilter field:=7, Criteria1:=Target
End With
Nb = .Range("A3:A" & LastLig).SpecialCells(xlCellTypeVisible).Count - 1
If Nb > 0 Then
Application.EnableEvents = False
.Range("A4:F" & LastLig).SpecialCells(xlCellTypeVisible).Copy Range("A4")
.Range("I4:J" & LastLig).SpecialCells(xlCellTypeVisible).Copy Range("G4")
.Range("L4:M" & LastLig).SpecialCells(xlCellTypeVisible).Copy
Range("J4").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.EnableEvents = True
End If
.Range("A3").AutoFilter
Range("A3").Select
End With
Range("A3").Select
ActiveWorkbook.Worksheets("J").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("J").Sort.SortFields.Add Key:=Range("K4:K299"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("J").Sort.SortFields.Add Key:=Range("B4:B299"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("J").Sort
.SetRange Range("A3:L500")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A3").Select
End If
End If
AutoFitSheet
End Sub |