Bonjour,

Débutant en VBA, j'ai un problème dans ma procédure, elle ne fonctionne qu'une fois sur 3 voir moins , je bug au niveau de l'ActiveSheet.Paste en rouge.

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
Sheets("SYSTEMATIQUE").Select

Sheets("SYSTEMATIQUE").Unprotect Password:="remi"
ActiveSheet.Unprotect Password:="remi"

Columns("A:V").AutoFilter

Sheets("SYSTEMATIQUE").Unprotect Password:="remi"
ActiveSheet.Unprotect Password:="remi"

'aller rechercher la systématique

Dim numérosyst As String
Dim celluletrouveesyst As Range
Dim lignesyst As Integer
Dim colsyst As Integer

numérosyst = SM_Box

Set celluletrouveesyst = Range("A:A").Find(numérosyst, lookat:=xlWhole)

If celluletrouveesyst Is Nothing Then
MsgBox "Numéro de systématique non valide"
Exit Sub
End If

lignesyst = celluletrouveesyst.Row
colsyst = celluletrouveesyst.Column

' Remplacer la date de derniere intervention

Range("P" & lignesyst) = CDate(Date_sold_Box.Value)

' Remplacer la durée

If Duréee_Real_Box.Value <> "" Then
Range("O" & lignesyst) = Duréee_Real_Box.Value
End If

' supprimer en cours + responsable

Range("U" & lignesyst).Clear
Range("V" & lignesyst).Clear

' mise en forme de la ligne

Range("U" & lignesyst & ":V" & lignesyst).Select
    Selection.RowHeight = 50
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Normal"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
    End With
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With


ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
        False, AllowFiltering:=True, AllowUsingPivotTables:=True

' Mise à jour dans l'historique

Range("A" & lignesyst & ":S" & lignesyst).Select
Selection.Copy

Sheets("HISTO.SYSTEMATIQUE").Select

Sheets("HISTO.SYSTEMATIQUE").Unprotect Password:="remi"
ActiveSheet.Unprotect Password:="remi"


Dercell = Range("A65000").End(xlUp).Row + 1
Range("A" & Dercell).Select

ActiveSheet.Paste

' Donner l'auteur

Dercell = Range("A65000").End(xlUp).Row
Range("T" & Dercell) = Auteur_ComboBox
    
    ' Donner l'observation

Dercell = Range("A65000").End(xlUp).Row
Range("U" & Dercell) = Observ_Box

' Mettre en forme la ligne

Range("A" & ActiveCell.Row & ":U" & ActiveCell.Row).Select
Selection.RowHeight = 50
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Normal"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
    End With
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With

ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
        False, AllowFiltering:=True, AllowUsingPivotTables:=True


' Retourner à la feuille systématique
Sheets("SYSTEMATIQUE").Select
ActiveSheet.Rows(ActiveCell.Row).EntireRow.Select

ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
        False, AllowFiltering:=True, AllowUsingPivotTables:=True

MsgBox "La date à été mise à jour !", vbInformation, _
"Systématique soldée !"

'sauvegarde automatique
ActiveWorkbook.Save
End

Je ne comprend pas pourquoi avant elle fonctionné très bien depuis j'ai changer les multiples .

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
Selection.AutoFilter Field:=1
        Selection.AutoFilter Field:=2
          Selection.AutoFilter Field:=...
                Selection.AutoFilter Field:=22
par

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
Columns("A:V").AutoFilter
Est-il possible que ca vienne de là??

Je suppose que mon code n'est pas assez "bien fait" pour fonctionner correctement.

D'avance merci de prendre le temps de m'aider.

Cordialement