Ejemplo 1: excel vba establecer borde alrededor del rango
'VBA routine to set the border AROUND or THROUGH a range:
Sub SetRangeBorders(r As Range, Optional edges As Boolean = 1, Optional stl = 1, Optional clr = 0, Optional wgt = 2)
Dim e
If edges Then
For Each e In Array(xlEdgeLeft, 8, 9, 10)
SetBorder r.Borders(e), stl, clr, wgt
Next
Else
SetBorder r.Borders, stl, clr, wgt
End If
End Sub
Sub SetBorder(b, Optional stl = 1, Optional clr = 0, Optional wgt = 2)
b.LineStyle = stl
b.Color = clr
b.Weight = wgt
End Sub
'--------------------------------------------------------------------
SetRangeBorders [d2:k10]
SetRangeBorders [d2:k10], False, vbRed
SetRangeBorders [d2:k10], , , xlThick
Ejemplo 2: fronteras vba de excel
Dim wksWorksheet As Worksheet, rRange As Range
Set wksWorksheet = ThisWorkbook.Worksheets(1)
Set rRange = wksWorksheet.Range("A1:D10")
' All borders
With rRange.Borders
.LineStyle = xlContinuous
.Color = vbRed
.Weight = xlThin
End With
' Outside borders
rRange.BorderAround xlContinuous, xlMedium, xlColorIndexAutomatic
' Inside
With rRange.Borders.Item(xlInsideHorizontal)
.ColorIndex = 5
.LineStyle = xlContinuous
.Weight = xlThin
End With
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)