Bonjour,

Novice sous VBA. J'ai créer un code sur quelques lignes pour imprimer rapidement plusieurs centaines de courriers sous Excel.

Voici le code de ma macro :

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
Sub pp()
'
' pp Macro
'
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False

    Range("K11").Select
    ActiveCell.FormulaR1C1 = "=+R[-4]C[5]"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
        
    Range("K11").Select
    ActiveCell.FormulaR1C1 = "=+R[-3]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
        
    ActiveCell.FormulaR1C1 = "=+R[-2]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
        
    ActiveCell.FormulaR1C1 = "=+R[-1]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
        
    ActiveCell.FormulaR1C1 = "=+R[0]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
        
    ActiveCell.FormulaR1C1 = "=+R[1]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[2]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[3]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[4]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[5]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[6]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[7]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    ActiveCell.FormulaR1C1 = "=+R[8]C[5]"
    Range("K11").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    
    
End Sub
Comme vous pouvez le voir c'est toujours le même code qui se répète avec ce qui est en gras qui se décale à chaque fois.
Je pense qu'il est possible d'automatiser ce code dans un code simple mais je ne te trouve pas ...
Merci beaucoup pour votre aide.