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

Excel macro to draw borders

Does a border belong to a cell? The following script shows it doesn't:
sub borders

    dim rng as range

    ' hide grid
    activeWindow.displayGridlines = false

    set rng = cells(3,3)

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

    set rng = cells(4,3)

    ' Setting the bottom border for cell 3,3 affects
    ' the top border for cell 4,3:
    msgbox ("xlMedium=" & xlMedium & ", this border's is: " & rng.borders(xlEdgeTop).weight) 
end sub