bordure mfc

GHISLAIN

XLDnaute Impliqué
bonsoir a tous

sous la mise en forme conditionnelle j arrive a encadrer mes cellules non vides

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
Selection.FormatConditions(1).StopIfTrue = True
End Sub


ce que je souhaiterais c est que toute la ligne soit encadrer de A a J si la premiere cellule en A est remplie

merci a tous de votre aide

amicalement

ghislain
 

phlaurent55

Nous a quittés en 2020
Repose en paix
Re : bordure mfc

Bonjour Ghislain,

avec ce code:
Code:
Sub Macro1()
'Valable pour les 20 premières lignes
    Range("A1:J20").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1<>"""""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Borders(xlLeft)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Borders(xlRight)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Borders(xlTop)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Borders(xlBottom)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Selection.FormatConditions(1).StopIfTrue = False
End Sub

à+
Philippe
 

GHISLAIN

XLDnaute Impliqué
Re : bordure mfc

bonsoir phlaurent55,

merci de t etre penchée sur mon fil

il ne serais pas possible de chercher jusqu a la derniere ligne rempli pour lance code ??

mon fichier va etre alimentee donc ne sera jamais fixe en nombre de ligne

merci de ton aide

amicalement

ghislain