Home / User Contributed Macros / Apply Colored Border

Apply Colored Border


The following macro code will be used to apply colored border to the selected Range/Cell.
Public Sub ApplyThickBorder()
   With Selection.borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .color = RGB(0, 0, 255)
    End With
    With Selection.borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .color = RGB(0, 0, 255)
    End With
    With Selection.borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .color = RGB(0, 0, 255)   
        .Weight = xlThick
    End With
    With Selection.borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .color = RGB(0, 0, 255)
    End With
    With Selection.borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .color = RGB(0, 0, 255)
    End With
    With Selection.borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .color = RGB(0, 0, 255)
    End With
End Sub
Change the RGB function values to get different colors.
Red   : RGB(255,0,0)
Green : RGB(0,255,0)
Blue : RGB(0,0,255)





     RSS of this page