René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Drawing borders [Excel macro]

sub draw_border

    dim rng as range

    ' hide grid
    activeWindow.displayGridlines = false

    set rng = range("c3:f6")

    rng.borders(xlEdgeLeft        ).lineStyle  = xlContinuous
    rng.borders(xlEdgeLeft        ).weight     = xlMedium
    rng.borders(xlEdgeLeft        ).colorIndex = xlAutomatic

    rng.borders(xlEdgeTop         ).lineStyle  = xlContinuous
    rng.borders(xlEdgeTop         ).weight     = xlMedium
    rng.borders(xlEdgeTop         ).colorIndex = xlAutomatic

    rng.borders(xlEdgeRight       ).lineStyle  = xlContinuous
    rng.borders(xlEdgeRight       ).weight     = xlMedium
    rng.borders(xlEdgeRight       ).colorIndex = xlAutomatic

    rng.borders(xlEdgeBottom      ).lineStyle  = xlContinuous
    rng.borders(xlEdgeBottom      ).weight     = xlMedium
    rng.borders(xlEdgeBottom      ).colorIndex = xlAutomatic

    rng.borders(xlInsideVertical  ).lineStyle  = xlDot       
    rng.borders(xlInsideVertical  ).weight     = xlHairline
    rng.borders(xlInsideVertical  ).colorIndex = xlAutomatic

    rng.borders(xlInsideHorizontal).lineStyle  = xlDot
    rng.borders(xlInsideHorizontal).weight     = xlHairline
    rng.borders(xlInsideHorizontal).colorIndex = xlAutomatic

    ' Other constants for lineStyle:
    '   xlDash
    '   xlDashDot
    '   xlDashDotDot
    '   xlDot
    '   xlDouble
    '   xlLineStyleNone
    '   xlSlantDashDot

    ' Other constants for weight:
    '   xlHairline
    '   xlMedium
    '   xlThick
    '   xlThin

end sub