Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Déclenchement de procédure

1 réponse
Avatar
Jean-Marc
Salut à tous,

Dans une feuille j'ai différentes macros liées à des boutons radio, des
cases à cocher, des boutons, ...
Certaines affichent des labels, changent des couleurs de cellules, y mettent
des cadres etc lorsqu'on clique sur un bouton radio.
Tout fonctionne bien.
J'ai créé un bouton de remise à 0 lançant une macro qui remet les valeurs
des cellules à leur valeur initiale.
Je voudrais que la macro (procédure) de remise à 0 lance toutes autres
procédures de cette feuille.
J'ai fait une série de tests mais les procédures ne fonctionnent pas
complètement. Les labels s'effacent, mais les cellules ne reprennent pas
leur couleur ni le cadre qu'il faut. Pourtant tout cela est dans la même
partie de la même procédure. Je ne comprend pas pq.

Voici un exemple des procédures :

Sub Ancestrale_Remise_a_0()
ActiveSheet.Unprotect
For Each s In ActiveSheet.Shapes
If s.Type = msoFormControl Then
If s.FormControlType = xlCheckBox Then _
s.ControlFormat.Value = False
s.Visible = True
End If
Next
Range("C3:C4,AC115").Value = 0
Range("E8,B21").ClearContents
Range("AB100,AB107,AB119") = 1
Range("AB122") = 2
Range("AB104") = 3
Range("C3").Select
Ancestrale_options
Ancestrale_Limitateurs
Ancestrale_Nbre_Carreaux
Ancestrale_options
ActiveSheet.Protect
End Sub



Sub Ancestrale_options()
ActiveSheet.Unprotect
If Range("AB107") >= 7 Then
With ActiveSheet.Shapes.Range(Array("VitrageInex", "VitrageGivre",
"VitrageGlueShip", "VitrageTeinte"))
.Visible = False
End With
Range("AB109:AB112") = False
Else
With ActiveSheet.Shapes.Range(Array("VitrageInex", "VitrageGivre",
"VitrageGlueShip", "VitrageTeinte"))
.Visible = True
End With
If IsError(Range("AC109")) Then
If Range("AB109") = True Then MsgBox ("Nous ne faisons pas de
vitrage Inex pour cette épaisseur de verre." & Chr(10) & Chr(13) & "Cette
option sera automatiquement désélectionnée."), vbExclamation, "Option non
valide"
Range("AB109") = False
With ActiveSheet.Shapes("VitrageInex")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageInex")
.Visible = True
End With
End If
If IsError(Range("AC110")) Then
If Range("AB110") = True Then MsgBox ("Nous ne faisons pas de
vitrage givré pour cette épaisseur de verre." & Chr(10) & Chr(13) & "Cette
option sera automatiquement désélectionnée."), vbExclamation, "Option non
valide"
Range("AB110") = False
With ActiveSheet.Shapes("VitrageGivre")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageGivre")
.Visible = True
End With
End If
If IsError(Range("AC111")) Then
If Range("AB111") = True Then MsgBox ("Nous ne faisons pas de
vitrage Glue Ship pour cette épaisseur de verre." & Chr(10) & Chr(13) &
"Cette option sera automatiquement désélectionnée."), vbExclamation, "Option
non valide"
Range("AB111") = False
With ActiveSheet.Shapes("VitrageGlueShip")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageGlueShip")
.Visible = True
End With
End If
If IsError(Range("AC112")) Then
If Range("AB112") = True Then MsgBox ("Nous ne faisons pas de
vitrage teinté pour cette épaisseur de verre." & Chr(10) & Chr(13) & "Cette
option sera automatiquement désélectionnée."), vbExclamation, "Option non
valide"
Range("AB112") = False
With ActiveSheet.Shapes("VitrageTeinte")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageTeinte")
.Visible = True
End With
End If
End If
If Range("AB107") = 10 Then
With ActiveSheet.Shapes("LabelVitrageSpecial")
.Visible = True
End With
Range("C13").Select
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
Selection.Interior.ColorIndex = xlNone
Selection.Locked = False
Selection.FormulaHidden = True
Selection.ClearContents
Else
With ActiveSheet.Shapes("LabelVitrageSpecial")
.Visible = False
End With
Range("C13").Borders(xlDiagonalDown).LineStyle = xlNone
Range("C13").Borders(xlDiagonalUp).LineStyle = xlNone
Range("C13").Borders(xlEdgeLeft).LineStyle = xlNone
Range("C13").Borders(xlEdgeTop).LineStyle = xlNone
Range("C13").Borders(xlEdgeBottom).LineStyle = xlNone
Range("C13").Borders(xlEdgeRight).LineStyle = xlNone
Range("C13").Borders(xlInsideVertical).LineStyle = xlNone
Range("C13").Borders(xlInsideHorizontal).LineStyle = xlNone
With Range("C13").Interior
.ColorIndex = 34
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("C13").Locked = True
Range("C13").FormulaHidden = True
Range("C13").ClearContents
End If
ActiveSheet.Protect
End Sub


Le LabelVitrageSpecial est rendu invisible quand je clique sur le bouton de
remise à 0, mais la case C13, par exemple ne reprend pas la bonne couleur et
le cadre ne disparait pas.


Merci de vos z'avis z'avisés,

JM

1 réponse

Avatar
mousnynao
Bonjour,

Avez-vous monitorer votre test !

Sur votre test :
If Range("AB107") = 10 Then
on devrait lire :
If Range("AB107").Value = 10 Then

mousnynao!

-----Message d'origine-----
Salut à tous,

Dans une feuille j'ai différentes macros liées à des
boutons radio, des

cases à cocher, des boutons, ...
Certaines affichent des labels, changent des couleurs de
cellules, y mettent

des cadres etc lorsqu'on clique sur un bouton radio.
Tout fonctionne bien.
J'ai créé un bouton de remise à 0 lançant une macro qui
remet les valeurs

des cellules à leur valeur initiale.
Je voudrais que la macro (procédure) de remise à 0 lance
toutes autres

procédures de cette feuille.
J'ai fait une série de tests mais les procédures ne
fonctionnent pas

complètement. Les labels s'effacent, mais les cellules ne
reprennent pas

leur couleur ni le cadre qu'il faut. Pourtant tout cela
est dans la même

partie de la même procédure. Je ne comprend pas pq.

Voici un exemple des procédures :

Sub Ancestrale_Remise_a_0()
ActiveSheet.Unprotect
For Each s In ActiveSheet.Shapes
If s.Type = msoFormControl Then
If s.FormControlType = xlCheckBox Then _
s.ControlFormat.Value = False
s.Visible = True
End If
Next
Range("C3:C4,AC115").Value = 0
Range("E8,B21").ClearContents
Range("AB100,AB107,AB119") = 1
Range("AB122") = 2
Range("AB104") = 3
Range("C3").Select
Ancestrale_options
Ancestrale_Limitateurs
Ancestrale_Nbre_Carreaux
Ancestrale_options
ActiveSheet.Protect
End Sub



Sub Ancestrale_options()
ActiveSheet.Unprotect
If Range("AB107") >= 7 Then
With ActiveSheet.Shapes.Range(Array
("VitrageInex", "VitrageGivre",

"VitrageGlueShip", "VitrageTeinte"))
.Visible = False
End With
Range("AB109:AB112") = False
Else
With ActiveSheet.Shapes.Range(Array
("VitrageInex", "VitrageGivre",

"VitrageGlueShip", "VitrageTeinte"))
.Visible = True
End With
If IsError(Range("AC109")) Then
If Range("AB109") = True Then MsgBox ("Nous ne
faisons pas de

vitrage Inex pour cette épaisseur de verre." & Chr(10) &
Chr(13) & "Cette

option sera automatiquement désélectionnée."),
vbExclamation, "Option non

valide"
Range("AB109") = False
With ActiveSheet.Shapes("VitrageInex")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageInex")
.Visible = True
End With
End If
If IsError(Range("AC110")) Then
If Range("AB110") = True Then MsgBox ("Nous ne
faisons pas de

vitrage givré pour cette épaisseur de verre." & Chr(10) &
Chr(13) & "Cette

option sera automatiquement désélectionnée."),
vbExclamation, "Option non

valide"
Range("AB110") = False
With ActiveSheet.Shapes("VitrageGivre")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageGivre")
.Visible = True
End With
End If
If IsError(Range("AC111")) Then
If Range("AB111") = True Then MsgBox ("Nous ne
faisons pas de

vitrage Glue Ship pour cette épaisseur de verre." & Chr
(10) & Chr(13) &

"Cette option sera automatiquement désélectionnée."),
vbExclamation, "Option

non valide"
Range("AB111") = False
With ActiveSheet.Shapes("VitrageGlueShip")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageGlueShip")
.Visible = True
End With
End If
If IsError(Range("AC112")) Then
If Range("AB112") = True Then MsgBox ("Nous ne
faisons pas de

vitrage teinté pour cette épaisseur de verre." & Chr(10)
& Chr(13) & "Cette

option sera automatiquement désélectionnée."),
vbExclamation, "Option non

valide"
Range("AB112") = False
With ActiveSheet.Shapes("VitrageTeinte")
.Visible = False
End With
Else
With ActiveSheet.Shapes("VitrageTeinte")
.Visible = True
End With
End If
End If
If Range("AB107") = 10 Then
With ActiveSheet.Shapes("LabelVitrageSpecial")
.Visible = True
End With
Range("C13").Select
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
Selection.Interior.ColorIndex = xlNone
Selection.Locked = False
Selection.FormulaHidden = True
Selection.ClearContents
Else
With ActiveSheet.Shapes("LabelVitrageSpecial")
.Visible = False
End With
Range("C13").Borders(xlDiagonalDown).LineStyle =
xlNone

Range("C13").Borders(xlDiagonalUp).LineStyle = xlNone
Range("C13").Borders(xlEdgeLeft).LineStyle = xlNone
Range("C13").Borders(xlEdgeTop).LineStyle = xlNone
Range("C13").Borders(xlEdgeBottom).LineStyle = xlNone
Range("C13").Borders(xlEdgeRight).LineStyle = xlNone
Range("C13").Borders(xlInsideVertical).LineStyle =
xlNone

Range("C13").Borders(xlInsideHorizontal).LineStyle =
xlNone

With Range("C13").Interior
.ColorIndex = 34
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("C13").Locked = True
Range("C13").FormulaHidden = True
Range("C13").ClearContents
End If
ActiveSheet.Protect
End Sub


Le LabelVitrageSpecial est rendu invisible quand je
clique sur le bouton de

remise à 0, mais la case C13, par exemple ne reprend pas
la bonne couleur et

le cadre ne disparait pas.


Merci de vos z'avis z'avisés,

JM


.