Est-ce que quelqu'un pourrait me dire pourquoi les bandes de couleurs
n'apparaissent pas?
J'ai pourtant inséré dans la procédure des MsgBox qui fonctionnent bien.
Merci à l'avance
*******************
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim iColor As Integer
'// Remarque : ne pas utiliser si vous avez des mises en forme
'// conditionnelles que vous souhaitez conserver
'// On Error reprend si l'utilisateur sélectionne une plage de cellules
On Error Resume Next
iColor = Target.Interior.ColorIndex
'// Laisse On Error ACTIVÉ pour les erreurs de décalage de lignes
If iColor < 0 Then
iColor = 36
Else
iColor = iColor + 1
End If
'// Test nécessaire si la couleur de la police est la même
If iColor = Target.Font.ColorIndex Then iColor = iColor + 1
Cells.FormatConditions.Delete
'// Bande de couleur horizontale
With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
'// Bande de couleur verticale
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
-Selectionner le champ A2:D16 -Format/Mise en forme conditionnelle =ET(LIGNE()ÎLLULE("ligne");COLONNE()<ÎLLULE("colonne")) =ET(COLONNE()ÎLLULE("colonne");LIGNE()<ÎLLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Calculate End Sub
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
-Selectionner le champ A2:D16
-Format/Mise en forme conditionnelle
=ET(LIGNE()=CELLULE("ligne");COLONNE()<=CELLULE("colonne"))
=ET(COLONNE()=CELLULE("colonne");LIGNE()<=CELLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Calculate
End Sub
'// Bande de couleur horizontale
With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
'// Bande de couleur verticale
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
-Selectionner le champ A2:D16 -Format/Mise en forme conditionnelle =ET(LIGNE()ÎLLULE("ligne");COLONNE()<ÎLLULE("colonne")) =ET(COLONNE()ÎLLULE("colonne");LIGNE()<ÎLLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Calculate End Sub
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
End Sub
JB
Il faut remplacer TRUE par VRAI .
JB
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim iColor As Integer
'// Remarque : ne pas utiliser si vous avez des mises en forme '// conditionnelles que vous souhaitez conserver
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="VRAI" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="VRAI" .FormatConditions(1).Interior.ColorIndex = iColor End With
-Selectionner le champ A2:D16 -Format/Mise en forme conditionnelle =ET(LIGNE()ÎLLULE("ligne");COLONNE()<ÎLLULE("colonne")) =ET(COLONNE()ÎLLULE("colonne");LIGNE()<ÎLLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Calculate End Sub
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
End Sub
Il faut remplacer TRUE par VRAI .
JB
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim iColor As Integer
'// Remarque : ne pas utiliser si vous avez des mises en forme
'// conditionnelles que vous souhaitez conserver
'// Bande de couleur horizontale
With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="VRAI"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
'// Bande de couleur verticale
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="VRAI"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
-Selectionner le champ A2:D16
-Format/Mise en forme conditionnelle
=ET(LIGNE()=CELLULE("ligne");COLONNE()<=CELLULE("colonne"))
=ET(COLONNE()=CELLULE("colonne");LIGNE()<=CELLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Calculate
End Sub
'// Bande de couleur horizontale
With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
'// Bande de couleur verticale
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="VRAI" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="VRAI" .FormatConditions(1).Interior.ColorIndex = iColor End With
-Selectionner le champ A2:D16 -Format/Mise en forme conditionnelle =ET(LIGNE()ÎLLULE("ligne");COLONNE()<ÎLLULE("colonne")) =ET(COLONNE()ÎLLULE("colonne");LIGNE()<ÎLLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Calculate End Sub
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
End Sub
JB
Coloriage de la ligne et colonne cellule active pour un champ -le champ ne doit pas avoir de couleur de fond -mais accepte les MFC
http://cjoint.com/?bcsRF2xgPu
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect([A2:D30], Target) Is Nothing And Target.Count = 1 Then [A1:D30].Interior.ColorIndex = xlNone Range(Cells(1, Target.Column), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 36 Range(Cells(Target.Row, 1), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 36 End If End Sub
-Selectionner le champ A2:D16 -Format/Mise en forme conditionnelle =ET(LIGNE()ÎLLULE("ligne");COLONNE()<ÎLLULE("colonne")) =ET(COLONNE()ÎLLULE("colonne");LIGNE()<ÎLLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Calculate End Sub
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
End Sub
Coloriage de la ligne et colonne cellule active pour un champ
-le champ ne doit pas avoir de couleur de fond
-mais accepte les MFC
http://cjoint.com/?bcsRF2xgPu
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect([A2:D30], Target) Is Nothing And Target.Count = 1
Then
[A1:D30].Interior.ColorIndex = xlNone
Range(Cells(1, Target.Column), Cells(Target.Row,
Target.Column)).Interior.ColorIndex = 36
Range(Cells(Target.Row, 1), Cells(Target.Row,
Target.Column)).Interior.ColorIndex = 36
End If
End Sub
-Selectionner le champ A2:D16
-Format/Mise en forme conditionnelle
=ET(LIGNE()=CELLULE("ligne");COLONNE()<=CELLULE("colonne"))
=ET(COLONNE()=CELLULE("colonne");LIGNE()<=CELLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Calculate
End Sub
'// Bande de couleur horizontale
With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
'// Bande de couleur verticale
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With
Coloriage de la ligne et colonne cellule active pour un champ -le champ ne doit pas avoir de couleur de fond -mais accepte les MFC
http://cjoint.com/?bcsRF2xgPu
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect([A2:D30], Target) Is Nothing And Target.Count = 1 Then [A1:D30].Interior.ColorIndex = xlNone Range(Cells(1, Target.Column), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 36 Range(Cells(Target.Row, 1), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 36 End If End Sub
-Selectionner le champ A2:D16 -Format/Mise en forme conditionnelle =ET(LIGNE()ÎLLULE("ligne");COLONNE()<ÎLLULE("colonne")) =ET(COLONNE()ÎLLULE("colonne");LIGNE()<ÎLLULE("ligne"))
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Calculate End Sub
'// Bande de couleur horizontale With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With
'// Bande de couleur verticale With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With