Toggle Borders

D

DianaH

Is there a way to toggle borders off and on ... the way
that word does it in a table.

I find it frustrating to have to remove the borders of an
entire cell, just so that I can remove the border on, say
the right side. I then have to re-apply the correct
border to the left and/or other borders (top and bottom)
to make this minor change.

Am I doing something wrong here? I have found this to be
very frustrating for a long time.
 
K

Ken Wright

Select the cell and do Format / Cell / Border - Then change just the one you
want to. No need to touch the others.
 
D

Don Guillett

Here is one I use to make borders and color cells and one I just created to
remove the borders.

Sub PrettyCells() 'Add borders & color
Dim myBorders
Dim i As Integer

myBorders = Array(, xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight)
For i = 1 To UBound(myBorders)
With Selection.Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
End With
Next

If Selection.Columns.Count > 1 Then _
Selection.Borders(xlInsideVertical).LineStyle = xlContinuous

If Selection.Rows.Count > 1 Then _
Selection.Borders(xlInsideHorizontal).LineStyle = xlContinuous

With Selection
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.ColorIndex = 5
.Font.Bold = True
End With
End Sub

Sub unborder()
myBorders = Array(, xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight,
xlInsideVertical, xlInsideHorizontal)
For i = 1 To UBound(myBorders)
Selection.Borders(myBorders(i)).LineStyle = xlNone
Next i
End Sub
 
G

Guest

Well Ken,
You know ... that worked, of course! That's how I used to
do it ... obviously, some time ago. I've gotten so use to
using the toggle feature in Word, that I'd forgotten about
it. I'd still like to see it, but your method did work,
just fine. Thanks for the quick response.
Diana
 
Top