Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle between two workbooks via MACRO Aligi Excel Discussion (Misc queries) 2 July 8th 08 08:43 PM
Toggle Macro Beep Beep Excel Programming 3 July 10th 07 12:29 PM
Toggle comments on or off macro Jim G Excel Discussion (Misc queries) 3 October 5th 06 04:07 AM
Macro Toggle On/Off Chipmunk Excel Programming 4 May 15th 06 08:21 PM
Toggle Macro Michael Excel Programming 5 June 11th 04 03:18 PM


All times are GMT +1. The time now is 08:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"