Macro : si cellule vide, sélectionner cette cellule

Résolu
Clotsy -  
 Clotsy -
Bonjour Sieurs et Dames de l'internet,

Je me tourne vers vous car je sens que mes compétences et ma patience ont atteint leurs limites respectives.
Mon problème est le suivant : je souhaiterais avoir une macro qui me détecte les cellules non vides. Une fois ces cellules détectées, je veux les sélectionner et leur appliquer une mise en forme particulière, c'est à dire encadrer la cellule avec des traits double. Dans la macro ci dessous, j'ai voulu en premier sélectionner les cellules non vides puis appliquer le format à cette sélection. Je ne suis pas sur d'avoir fait le bon choix, étant donné que ma macro ne marche pas !
Si vous voyez une solution, une piste, je suis preneur ! Car je tourne en rond depuis un petit moment !

Un grand merci à vous,
Clotsy

Dim cellule As Range
For Each cellule In Range("A5:J700")
If cellule <> "" Then Select.(cellule <> "")
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft).LineStyle = xlNone
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
With Selection.Borders(xlEdgeTop).LineStyle = xlNone
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
End With
End With
End With
Next
End Sub


1 réponse

  1. Gyrus Messages postés 3360 Statut Membre 526
     
    Bonjour,

    Essaie comme cela
    Sub Test()
    Dim cellule As Range
    Application.ScreenUpdating = False
    For Each cellule In Range("A5:J700")
    If cellule <> "" Then
    With cellule
    .Borders(xlDiagonalDown).LineStyle = xlNone
    .Borders(xlDiagonalUp).LineStyle = xlNone
    With .Borders(xlEdgeLeft)
    .LineStyle = xlDouble
    .Weight = xlThick
    .ColorIndex = xlAutomatic
    End With
    With .Borders(xlEdgeTop)
    .LineStyle = xlDouble
    .Weight = xlThick
    .ColorIndex = xlAutomatic
    End With
    With .Borders(xlEdgeBottom)
    .LineStyle = xlDouble
    .Weight = xlThick
    .ColorIndex = xlAutomatic
    End With
    With .Borders(xlEdgeRight)
    .LineStyle = xlDouble
    .Weight = xlThick
    .ColorIndex = xlAutomatic
    End With
    End With
    End If
    Next
    End Sub

    A+
    0
    1. Clotsy
       
      Tout simplement parfait ! Bravo et merci :)
      0