Bonjour le forum,

j'ai besoin de votre aide pour modifier le code ci-dessous qui me permettra d'exécuter une macro pour les quelques 200 lignes concernées sans avoir à écrire autant de fois la condition "If ....End if".

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
Sub Macro1()
'
' Macro1 Macro
'
 
'
 
If [A1] <> "" Then
            ActiveSheet.Unprotect
    Range("A1").Select
    Selection.Copy
    Range("D1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
End If
 
If [A2] <> "" Then
            ActiveSheet.Unprotect
    Range("A2").Select
    Selection.Copy
    Range("D2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
End If
 
If [A3] <> "" Then
            ActiveSheet.Unprotect
    Range("A3").Select
    Selection.Copy
    Range("D3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
 End If
 
   If [A4] <> "" Then
            ActiveSheet.Unprotect
    Range("A4").Select
    Selection.Copy
    Range("D4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
 End If
 
 
 
 
 
 
    If [A240] <> "" Then
            ActiveSheet.Unprotect
    Range("A240").Select
    Selection.Copy
    Range("D240").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
 End If
 
 
 
            ActiveSheet.Protect
End Sub
Je vous remercie pour vos réponses et vous souhaite une bonne fin de journée.
Cordialement.