1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Private Sub Appliquer_Les_Bordures(NomFeuille As String)
Dim DerCol As Integer
Dim DerLig As Long
Dim Bordure(), Elt As Variant
'Tableau avec le type de bordure à appliquer
Bordure = Array(xlEdgeTop, xlEdgeLeft, _
xlEdgeRight, xlInsideVertical)
With Worksheets(NomFeuille)
If Not IsEmpty(.UsedRange) Then
DerLig = .Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
DerCol = .Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
With .Range("A12", .Cells(DerLig, DerCol))
For Each Elt In Bordure
With .Borders(Elt)
.LineStyle = xlContinuous
.Weight = xlThin 'Or Thick
'Constantes couleurs disponibles
'vbRed , VBBroun, vbGreen, vbWhite
'vbCyan, vbBlue, vbYellow
.Color = vbBlack
End With
Next
End With
With .Range("C12", .Cells(DerLig, 3))
.Borders(xlEdgeLeft).LineStyle = xlNone
End With
End If
End With
End Sub |