Remove all borders from a range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using Office 2003 on Windows XP.

I recorded the code to remove ALL borders from a range and got the following:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

Is there a simpler code to just remove all the borders in a range of cells?
If so, could you please post example code?
Thanks much in advance.
 
Sub test()
Dim rng As Range

Set rng = ActiveSheet.Range("A1:B10")

rng.Borders.LineStyle = xlNone
End Sub
 
Yet one more instance where something so easy is made so complex when
recorded. At least you are savy enough to recognize garbage when you see it
and know that there just has to be a better way.
 
Hi,

in excel 2000, Borders.LineStyle doesn't change diagonal lines and the
borders of adjacent cells.
I suppose that if you want to delete them, something like the code you
wrote is needed. this is an example of looping:

Sub ClearBorders()
Dim b As Variant
For Each b In Array(xlDiagonalDown, xlDiagonalUp, _
xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight, _
xlInsideVertical, xlInsideHorizontal)
Selection.Borders(b).LineStyle = xlNone
Next
End Sub
 
Back
Top