Bonjour à tous,
Je suis nouveau, donc j'espère que je suis dans la bonne partie du forum.
Je me suis mis il y a peu de temps à VBA Excel (depuis hier), et j'ai un petit problème concernant une de mes macros.
Je suis un mini cour sur un livre, et je n'arrive pas au même résultat qu'eux, malgré que le code soit le même.
Le but de la macro est de créer automatiquement une page agenda, avec les jours et en onglet de feuille le mois + année.
Le problème est que lorsque j'éxécute la macro, il me demande le jour, moi et année que je veux, et après il ne me remplit dans la cononne choisit, que le jour que j'ai écrit alors qu'il faudrait qu'il écrive tous les jours du mois.
Je mets le programme ci dessous:
Je n'ai pas encore assez de recul pour comprendre ou je peux avoir faux.
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 Sub Agenda() ' ' Agenda Macro ' Génère des feuilles d'agenda ' ' Sheets.Add Range("A3:B33").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With Range("A1").Select Selection.NumberFormat = "mmmm yyyy" Range("A3:B33").Select Selection.NumberFormat = "dddd d" Columns("A:A").Select Selection.ColumnWidth = 20 Columns("B:B").Select Selection.ColumnWidth = 60 Range("A1:B1").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = False End With Selection.Merge With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = True End With With Selection.Font .Name = "Arial" .Size = 20 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With DateChoisie = InputBox("Entrez la date de la feuille (00/00/00)") ActiveSheet.Name = Format(DateChoisie, "mmmm yyyy") DateChoisie = DateValue(DateChoisie) Range("A1") = DateChoisie MoiEnCours = Month(DateChoisie) Fond = 15 For JourEnCours = 3 To 33 Cells(JourEnCours, 1) = DateChoisie Cells(JourEnCours, 1).Interior.ColorIndex = Fond If Weekday(DateChoisie) = 1 Then Fond = 0 Else Fond = 15 End If DateChoisie = DateChoisie + 1 If Month(DateChoisie) > MoisEnCours Then Exit For Next JourEnCours Range("B3").Select End Sub
Si vous pouviez m'aider.
Merci.
Partager