Bonjour,

J'ouvre un classeur A et je lance une macro, qui trie et copie certaine données.
Ensuite j'ouvre un classeur Suivi, je colle les données et les trie.
Ensuire sur le classeur A, je veux effacer les lignes qui ont été copiées/collées.

Mais j'ai une erreur 1004 "methode delete classe range échoué" à la ligne 55
voila la procédure complete.

Pourquoi je ne peux pas effacer ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
Sub Export_vers_base()
 
Application.ScreenUpdating = False
ActiveSheet.Unprotect
 
  Dim classeurA As Workbook
  Dim Cell As Range
  Dim Resultat As String
 
  Set classeurA = ActiveWorkbook
 
For Each Cell In Range("P3:P65536")
 If Not Cell = "" Then
 Resultat = Resultat & Cell.Address & Chr(10)
 End If
 Next Cell
 
If Resultat = "" Then
 msgbox "Aucune fiche à exporter"
 
 Else
 
'activer le tri des lignes dont la colonne "Com" est vide et copier
    ActiveSheet.Range("A1").AutoFilter Field:=16, Criteria1:="<>"
        Range("A3:Q" & Range("A65536").End(xlUp).Row).Copy
 
'Ouvrir le fichier suivi et coller
    Workbooks.Open Filename:="G:\Commun\03-Suivi\Fichier Suivi.xlsm"
    Range("A65536").End(xlUp).Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    ActiveSheet.Paste
    Range("A65536").End(xlUp).Offset(1, 0).Select
        Application.CutCopyMode = False
' Trie par date de fiche (colonne L)
    Range("A3:W" & Range("A65536").End(xlUp).Row).Select
    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("L3:L65536") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Feuil1").Sort
        .SetRange Range("A2:W" & Range("A65536").End(xlUp).Row)
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Range("D3").Select
    ActiveWorkbook.Save
    ActiveWorkbook.Close
 
'supprimer les lignes concerné par le tri sans mesage d'alerte
        Application.DisplayAlerts = False
        classeurA.Worksheets("Sheet0").Range("A3:Q" & Range("A65536").End(xlUp).Row).Delete
        Application.DisplayAlerts = True
 
'supprimer le trie des lignes
    With Worksheets("sheet0")
    If .FilterMode = True Then .ShowAllData
        End With
 
' Fin
    Application.ScreenUpdating = True
    msgbox "Les fiches ont été exporté", vbOKOnly
    ActiveWorkbook.Save
 
 End If
Range("D3").Select
ActiveSheet.Protect
 
End Sub