toggle borders macro
Try this
Public Enum borderStyle
TopCell = 1
LeftCell = 2
TopCornerCell = 3
End Enum
Sub ToggleBorders()
With Selection
If .Row = 1 And .Column = 1 Then
MyStyle = TopCornerCell
Else
If .Row = 1 And .Column = 1 Then
MyStyle = TopCornerCell
End If
If .Row = 1 And .Column = 1 Then
MyStyle = TopCornerCell
End If
End If
Select Case MyStyle
Case TopCell
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
End Select
End With
End Sub
Another method
Sub ToggleBorders()
With Selection
For Edge = xlDiagonalDown To xlInsideVertical
Case xlDiagonalDown '=5
.Borders(Edge).LineStyle = xlContinuous
Case xlDiagonalUp '=6
Case xlEdgeLeft '=7
Case xlEdgeTop '=8
Case xlEdgeBottom '=9
Case xlEdgeRight '=10
Case xlInsideHorizontal '=11
Case xlInsideVertical '=12
Next edge
End With
End Sub
"pwilson.bowdoin" wrote:
I'm trying to create a macro that will cycle between border options.
(edgetop, edgeright,edgebottom, edgeleft, outline cell)
I have been trying to do this using the select case function but have
been unsuccessful. Is it possible to have multiple prerequisites with
the select case function?
My main problem is dealing with the (xlEdgetop) modifier in the select
case function.
Thanks for the help1
Sub ToggleBorders()
With Selection
Select Case .Borders.LineStyle
Case xlNone
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
End Select
End With
End Sub
|