Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
toggle borders macro
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
toggle borders macro
For the second method don't we need a select case function to agree
with the Case's below. The method which I'm referring to is below. Thanks for the help! 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
toggle borders macro
I just wanted to give you some ideas so you could solve your own problem.
"pwilson.bowdoin" wrote: For the second method don't we need a select case function to agree with the Case's below. The method which I'm referring to is below. Thanks for the help! 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Toggle between two workbooks via MACRO | Excel Discussion (Misc queries) | |||
Toggle Macro | Excel Programming | |||
Toggle comments on or off macro | Excel Discussion (Misc queries) | |||
Macro Toggle On/Off | Excel Programming | |||
Toggle Macro | Excel Programming |