Border Object and the Borders Collection Example

Applies a 3D effect to a range:

Sub TestFormat3D()

'Format the selected range as 3D sunken

Format3D Selection

End Sub

Sub Format3D(oRange As Range, Optional bSunken As Boolean =

True)

'Using the range(

With oRange

'Surround it with a white border

.BorderAround Weight:=xlMedium, Color:=RGB(255, 255,

255)

If bSunken Then

'Sunken, so make the left and top dark-grey

.Borders(xlEdgeLeft).Color = RGB(96, 96, 96)

.Borders(xlEdgeTop).Color = RGB(96, 96, 96)

Else

'Raised, so make the right and bottom dark-grey

.Borders(xlEdgeRight).Color = RGB(96, 96, 96)

.Borders(xlEdgeBottom).Color = RGB(96, 96, 96)

End If

End With

End Sub

0 0

Post a comment