Macro raccourcir code mise en forme

Bonjour.

Voilà mon code pour que le contour de la zone ("F1:H4") soit un trait noir épais.

Est-il possible de le raccourcir ?

Merci

Range("F1:H4").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

Bonjour,

Peut-être ainsi :

With Range("F1:H4")
    With .Borders
        .Weight = xlMedium
    End With
    With .Borders(xlInsideVertical)
        .Weight = xlThin
    End With
    With .Borders(xlInsideHorizontal)
        .Weight = xlThin
    End With
End With

Bonne journée

Bonjour à tous

encore plus bref!

With Range("F1:H4")
.Borders.Weight = xlThin
.BorderAround Weight:=xlMedium
End With

edit: ajouté quadrillage intérieur (j'avais pas lu la macro!)

Merci pour la réponse qui marche très bien.

maintenant, j'ai un problème avec ces codes :

Sheets(Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11")).Add.Name
Sheets.Add.Name = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"

Je souhaite créer toutes ces feuilles en même temps, mais aucun des deux codes ci dessus ne fonctionnent

Re-,

Par exemple :

lesnoms = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11")
For Each lnms In lesnoms
    Sheets.Add.Name = lnms
Next lnms

si tu veux les placer après les feuilles :

lesnoms = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11")
For Each lnms In lesnoms
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Name = lnms
Next lnms

Bonne soirée

Rechercher des sujets similaires à "macro raccourcir code mise forme"