Colorer bordures c'une cellule Excel)

Résolu
BABUDROME Messages postés 151 Date d'inscription lundi 16 janvier 2006 Statut Membre Dernière intervention 19 avril 2016 - 9 nov. 2015 à 15:14
BABUDROME Messages postés 151 Date d'inscription lundi 16 janvier 2006 Statut Membre Dernière intervention 19 avril 2016 - 10 nov. 2015 à 15:08
Bonjour,
Je sais colorer les bordures d'une cellule en ROUGE, EN JAUNE,... mais je voudrais bien les colorer en GRIS, même couleur que je colore le fond de la cellule dans le code ci-dessous. Le GRIS du fond est obtenu via l'enregistrement d'une macro.
Est-ce possible ? Si oui, comment ?


Sub ColorerCell(Adr$, coul$)
ActiveSheet.Range(Adr).Select
Select Case UCase(Left(coul, 4))
Case Is = "BLAN": With Selection.Interior: .Pattern = xlSolid: .PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1: .TintAndShade = 0: .PatternTintAndShade = 0: End With
Case Is = "NOIR": With Selection.Interior: .Pattern = xlSolid: .PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1: .TintAndShade = 0: .PatternTintAndShade = 0: End With
Case Is = "JAUN": With Selection.Interior: .Pattern = xlSolid: .PatternColorIndex = xlAutomatic
.Color = 65535: .TintAndShade = 0: .PatternTintAndShade = 0: End With:
Case Is = "GRIS": With Selection.Interior: .Pattern = xlSolid: .PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1: .TintAndShade = -0.249977111117893: .PatternTintAndShade = 0: End With
Case Is = "ROUG": With Selection.Interior: .Pattern = xlSolid: .PatternColorIndex = xlAutomatic
.Color = 255: .TintAndShade = 0: .PatternTintAndShade = 0: End With
End Select: End Sub

Sub ColorerCadre(ByVal X$, ByVal Koul$) ' colore les 4 côtés de la case
Dim coul As Double
Select Case UCase(Left(Koul, 4))
Case Is = "BLAN": coul = vbWhite '0
Case Is = "NOIR": coul = vbBlack '1
Case Is = "JAUN": coul = vbYellow '6
' Case Is = "GRIS": coul = ?
Case Else: Info " ColorerCadre erreur couleur !"
End Select:
Range(X).Select
With Selection: ' .Borders(xlDiagonalDown).LineStyle = xlNone: .Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft): .LineStyle = xlContinuous: .ColorIndex = coul: .TintAndShade = 0: .Weight = xlThin: End With
With .Borders(xlEdgeTop): .LineStyle = xlContinuous: .ColorIndex = coul: .TintAndShade = 0: .Weight = xlThin: End With
With .Borders(xlEdgeBottom): .LineStyle = xlContinuous: .ColorIndex = coul: .TintAndShade = 0: .Weight = xlThin: End With
With .Borders(xlEdgeRight): .LineStyle = xlContinuous: .ColorIndex = coul: .TintAndShade = 0: .Weight = xlThin: End With: End With: End Sub

bab

1 réponse

ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
10 nov. 2015 à 08:08
Bonjour,
Je ne te comprends pas.
Donner aux bordures d'une cellule la couleur de fond de cette cellule revient tout simplement à ne pas donner de bordure, ainsi (exemple)
With Range("B11")
With .Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.249977111117893
.PatternTintAndShade = 0
End With
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With

0
BABUDROME Messages postés 151 Date d'inscription lundi 16 janvier 2006 Statut Membre Dernière intervention 19 avril 2016
10 nov. 2015 à 15:08
Salut. tu as raison, je deviens sénile.
Axé (obnubilé plutôt) par un routine permettant de colorer les bords, j'ai oublier que l'absence de bords m'assurer de mon besoin.
Désolé de t'avoir sollicité pour si peu, mais tu m'as quand rendu service et donc MERCI.
Bab
0
Rejoignez-nous