Bonjour,
J'ai créé une macro qui met une mise en forme conditionnelle dans une plage de cellule en fonction d'un tableau (Min et Max avec les couleurs).
Ma macro demande de sélectionner le tableau avec les valeurs min et max et leurs couleurs associées, puis de sélectionner la plage de cellule sur lequel on va appliquer la MEF conditionnelle.
Ma macro marche parfaitement, je peux sélectionner ma plage de cellule avec les touches ctrl+shift et les flèches.
Mais hier j'ai créér une macro avec un formulaire (qui me sert de menu) qui regroupe plusieurs autres macros.
Depuis je ne peux plus faire ma sélection avec les touches Ctrl+Shift + flèches, je dois sélectionner ma plage avec la souris. Quand on a 200 colonnes c'est chiant.
Ma macro menu comporte 7 modules (1 par macro + 1 pour les fonctions communes + 1 qui lance le formulaire)
Mon module de lancement comporte unique un show pour lancer le formulaire.
Mon formulaire à 5 checkbox et 1 bouton.
Voici son code :
Voici maintenant ma macro de MEF Conditionnelle :
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 Option Explicit 'Déclaration des variables Public Choix_PDC As Integer Public Choix_DataMap As Integer Public Choix_Stat As Integer Public a As Integer Public b As Integer Public c As Integer Public h As Integer Public i As Integer Public j As Integer Public k As Integer Public l As Integer Public m As Integer Public q As String Public s As Integer Public t As String Public Z As Integer Public Deb As Integer Public nbl As Integer Public nbli As Integer Public nbli2 As Integer Public nbli3 As Integer Public nblipdc As Integer Public Col As Integer Public NbCol As Integer Public WS_Count As Integer Public cp As Integer Public cp2 As Integer Public score As Integer Public score2 As String Public rep As Integer Public repST As String Public RGBC As Integer Public Red As Integer Public Green As Integer Public Blue As Integer Public Theme As Object Public LigDeb_Theme As Long Public Nom_Onglet_Theme As Range Public ww As Range Public MEF As Object Public ColDeb_MEF As Integer Public ColFin_MEF As Integer Public LigDeb_MEF As Long Public LigFin_MEF As Long Public Nom_Onglet_MEF As Range Public DATA As Object Public ColDeb_DATA As Integer Public ColFin_DATA As Integer Public LigDeb_DATA As Long Public LigFin_DATA As Long Public Nom_Onglet_DATA As Range Public REF As Object Public ColDeb_REF As Integer Public LigDeb_REF As Long Public Nom_Onglet_REF As Range Public debut As Date Public temps As Date Public fin As Date Sub DataMap_Click() If DataMap.Value = True Then PDC.Value = False Verif_Code.Value = False Suppr_Conserv_Couleur.Value = False MEF_Conditionnel.Value = False End If End Sub Sub MEF_Conditionnel_Click() If MEF_Conditionnel.Value = True Then DataMap.Value = False Verif_Code.Value = False Suppr_Conserv_Couleur.Value = False PDC.Value = False End If End Sub Sub PDC_Click() If PDC.Value = True Then DataMap.Value = False Verif_Code.Value = False Suppr_Conserv_Couleur.Value = False MEF_Conditionnel.Value = False End If End Sub Sub Suppr_Conserv_Couleur_Click() If Suppr_Conserv_Couleur.Value = True Then DataMap.Value = False Verif_Code.Value = False PDC.Value = False MEF_Conditionnel.Value = False End If End Sub Private Sub UserForm_Activate() DataMap.Value = False Verif_Code.Value = False PDC.Value = False MEF_Conditionnel.Value = False Suppr_Conserv_Couleur.Value = False End Sub Sub Verif_Code_Click() If Verif_Code.Value = True Then DataMap.Value = False PDC.Value = False Suppr_Conserv_Couleur.Value = False MEF_Conditionnel.Value = False End If End Sub Sub Lancement_Click() If PDC.Value = True Then UserForm1.Hide Call Module_PDC.PDC End If If DataMap.Value = True Then UserForm1.Hide Call Module_DataMap.DataMap End If If Suppr_Conserv_Couleur.Value = True Then UserForm1.Hide Call Module_Suppr_Conserv_Couleur.Suppr_Conserv_par_Couleur End If If Verif_Code.Value = True Then UserForm1.Hide Call Module_Verif_Code.Verif_Code End If If MEF_Conditionnel.Value = True Then UserForm1.Hide Call Module_MEF_Conditionnel.MEF_Conditionnel End If End Sub
Merci de votre aide!!
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 Function MEF_Conditionnel() debut = Time Choix_Stat = MsgBox("Voulez vous exécuter la macro de Mise En Forme Conditionnelle (Uniquement les couleurs) ?", vbYesNo) If Choix_Stat = 7 Then MsgBox ("Macro annulée") Exit Function End If If Choix_Stat = 6 Then 'Programme MEF_VITRAUX_STAT On Error Resume Next Set MEF = Application.InputBox(prompt:="Sélectionnez la plage de cellules pour la MEF Conditionnelle, juste le Min et le Max", Type:=8) If Err > 0 Then MsgBox ("Macro annulée") Exit Function End If Set Nom_Onglet_MEF = MEF.CurrentRegion ColDeb_MEF = MEF(1, 1).Column ColFin_MEF = MEF(1, MEF.Columns.Count).Column LigDeb_MEF = MEF(1, 1).Row LigFin_MEF = MEF(MEF.Rows.Count, 1).Row On Error Resume Next Set DATA = Application.InputBox(prompt:="Sélectionnez la plage de cellules de données à mettre en forme", Type:=8) If Err > 0 Then MsgBox ("Macro annulée") Exit Function End If Set Nom_Onglet_DATA = DATA.CurrentRegion ColDeb_DATA = DATA(1, 1).Column ColFin_DATA = DATA(1, DATA.Columns.Count).Column LigDeb_DATA = DATA(1, 1).Row LigFin_DATA = DATA(DATA.Rows.Count, 1).Row Range(Cells(LigDeb_DATA, ColDeb_DATA), Cells(LigFin_DATA, ColFin_DATA)).Select With selection.Interior .Pattern = xlNone .TintAndShade = 0 .PatternTintAndShade = 0 End With Range(Cells(LigDeb_DATA, ColDeb_DATA), Cells(LigFin_DATA, ColFin_DATA)).Select selection.FormatConditions.Delete For i = ColDeb_MEF To ColFin_MEF Val1 = "=" & Cells(LigDeb_MEF, i) Val2 = "=" & Cells(LigFin_MEF, i) selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _ Formula1:=Val1, Formula2:=Val2 selection.FormatConditions(selection.FormatConditions.Count).SetFirstPriority With selection.FormatConditions(1) .Interior.Color = RVB(Cells(LigFin_MEF, i)) .Font.Color = RVBTEXT(Cells(LigFin_MEF, i)) .Borders.Color = RVBBORDER(Cells(LigFin_MEF, i)) End With selection.FormatConditions(1).StopIfTrue = False Next i fin = Time temps = fin - debut MsgBox ("C'est fini !" & Chr(10) & "temps de traitement " & temps) End If End Function
PS : a une autre question/Pb, Avant que je ne mette ma macro dans la macro menu, mon temps s'affichait en forma date/heure, maintenant il me met la valeur de la date.
Si vous pouviez aussi résoudre ce pb ca m'arrangerai.
Merci!!
Partager