Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Tom Tom is offline
external usenet poster
 
Posts: 5
Default A toggling border macro

On selecting an entire row, how to create a macro (which is to be attached
to a button) that colours the top and bottom borders light red. Upon
reclicking (toggling) the button the coloured borders disappear. This
process is to repeat itself. Thanks for any help.

TIA
Tom


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default A toggling border macro

Attach the macro given below to a button and test...
to test select any row and press once to get borders and again to clear...
it will toggle the top and bottom borders for the current selection

Sub toggleBorders()
If Selection.Borders(xlEdgeTop).LineStyle = xlNone Then
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
ElseIf Selection.Borders(xlEdgeTop).LineStyle = xlContinuous Then
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Else
'do nothing
End If
End Sub

"Tom" wrote:

On selecting an entire row, how to create a macro (which is to be attached
to a button) that colours the top and bottom borders light red. Upon
reclicking (toggling) the button the coloured borders disappear. This
process is to repeat itself. Thanks for any help.

TIA
Tom



  #3   Report Post  
Posted to microsoft.public.excel.misc
Tom Tom is offline
external usenet poster
 
Posts: 5
Default A toggling border macro

It works perfectly. Thanks very much Sheeloo.

Tom
"Sheeloo" wrote in message
...
Attach the macro given below to a button and test...
to test select any row and press once to get borders and again to clear...
it will toggle the top and bottom borders for the current selection

Sub toggleBorders()
If Selection.Borders(xlEdgeTop).LineStyle = xlNone Then
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
ElseIf Selection.Borders(xlEdgeTop).LineStyle = xlContinuous Then
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Else
'do nothing
End If
End Sub

"Tom" wrote:

On selecting an entire row, how to create a macro (which is to be
attached
to a button) that colours the top and bottom borders light red. Upon
reclicking (toggling) the button the coloured borders disappear. This
process is to repeat itself. Thanks for any help.

TIA
Tom





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default A toggling border macro

A bit of a variation.

Sub toggleborders()
With Selection.EntireRow
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
..Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
On selecting an entire row, how to create a macro (which is to be attached
to a button) that colours the top and bottom borders light red. Upon
reclicking (toggling) the button the coloured borders disappear. This
process is to repeat itself. Thanks for any help.

TIA
Tom


  #5   Report Post  
Posted to microsoft.public.excel.misc
Tom Tom is offline
external usenet poster
 
Posts: 5
Default A toggling border macro

It works beautifully. Thanks Don. One question, lets say if I wanted to
limit the length of the row to only 40 cells, how do you modify the codes?
Much appreciate for your help.

Tom

"Don Guillett" wrote in message
...
A bit of a variation.

Sub toggleborders()
With Selection.EntireRow
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
On selecting an entire row, how to create a macro (which is to be
attached to a button) that colours the top and bottom borders light red.
Upon reclicking (toggling) the button the coloured borders disappear.
This process is to repeat itself. Thanks for any help.

TIA
Tom






  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default A toggling border macro

Change to
Sub toggleborders()
'With Selection.EntireRow
With Cells(ActiveCell.Row, 1).Resize(, 40)
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
..Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
That is after selecting the entire row, then limit the top and bottom
borders
to 40 column cells along that row.

"Don Guillett" wrote in message
...
Which 40? Rows/columns, from where.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
It works beautifully. Thanks Don. One question, lets say if I wanted to
limit the length of the row to only 40 cells, how do you modify the
codes? Much appreciate for your help.

Tom

"Don Guillett" wrote in message
...
A bit of a variation.

Sub toggleborders()
With Selection.EntireRow
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
On selecting an entire row, how to create a macro (which is to be
attached to a button) that colours the top and bottom borders light
red. Upon reclicking (toggling) the button the coloured borders
disappear. This process is to repeat itself. Thanks for any help.

TIA
Tom








  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default A toggling border macro


BTW, this works the same if you select the row number or any cell in the
row.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
Change to
Sub toggleborders()
'With Selection.EntireRow
With Cells(ActiveCell.Row, 1).Resize(, 40)
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
That is after selecting the entire row, then limit the top and bottom
borders
to 40 column cells along that row.

"Don Guillett" wrote in message
...
Which 40? Rows/columns, from where.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
It works beautifully. Thanks Don. One question, lets say if I wanted to
limit the length of the row to only 40 cells, how do you modify the
codes? Much appreciate for your help.

Tom

"Don Guillett" wrote in message
...
A bit of a variation.

Sub toggleborders()
With Selection.EntireRow
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
On selecting an entire row, how to create a macro (which is to be
attached to a button) that colours the top and bottom borders light
red. Upon reclicking (toggling) the button the coloured borders
disappear. This process is to repeat itself. Thanks for any help.

TIA
Tom









  #10   Report Post  
Posted to microsoft.public.excel.misc
Tom Tom is offline
external usenet poster
 
Posts: 5
Default A toggling border macro

Yes, it is very versatile and also clears up as long as the the active cell
is anywhere along the original row. Thanks once again for your help, Don.

Tom

"Don Guillett" wrote in message
...

BTW, this works the same if you select the row number or any cell in the
row.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
Change to
Sub toggleborders()
'With Selection.EntireRow
With Cells(ActiveCell.Row, 1).Resize(, 40)
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
That is after selecting the entire row, then limit the top and bottom
borders
to 40 column cells along that row.

"Don Guillett" wrote in message
...
Which 40? Rows/columns, from where.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
It works beautifully. Thanks Don. One question, lets say if I wanted
to limit the length of the row to only 40 cells, how do you modify the
codes? Much appreciate for your help.

Tom

"Don Guillett" wrote in message
...
A bit of a variation.

Sub toggleborders()
With Selection.EntireRow
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
On selecting an entire row, how to create a macro (which is to be
attached to a button) that colours the top and bottom borders light
red. Upon reclicking (toggling) the button the coloured borders
disappear. This process is to repeat itself. Thanks for any help.

TIA
Tom













  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default A toggling border macro

Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
Yes, it is very versatile and also clears up as long as the the active
cell is anywhere along the original row. Thanks once again for your help,
Don.

Tom

"Don Guillett" wrote in message
...

BTW, this works the same if you select the row number or any cell in the
row.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
Change to
Sub toggleborders()
'With Selection.EntireRow
With Cells(ActiveCell.Row, 1).Resize(, 40)
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
That is after selecting the entire row, then limit the top and bottom
borders
to 40 column cells along that row.

"Don Guillett" wrote in message
...
Which 40? Rows/columns, from where.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
It works beautifully. Thanks Don. One question, lets say if I wanted
to limit the length of the row to only 40 cells, how do you modify
the codes? Much appreciate for your help.

Tom

"Don Guillett" wrote in message
...
A bit of a variation.

Sub toggleborders()
With Selection.EntireRow
If .Borders.LineStyle = xlNone Then
myBorders = Array(, xlEdgeTop, xlEdgeBottom)
For i = 1 To UBound(myBorders)
With .Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 3
End With
Next
Else
.Borders.LineStyle = xlNone
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
On selecting an entire row, how to create a macro (which is to be
attached to a button) that colours the top and bottom borders light
red. Upon reclicking (toggling) the button the coloured borders
disappear. This process is to repeat itself. Thanks for any help.

TIA
Tom












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
Macro for a Border JSnow Excel Discussion (Misc queries) 2 September 3rd 08 07:51 PM
I need a macro for inserting a border line every 20 rows Adamp Excel Discussion (Misc queries) 9 August 20th 08 07:56 PM
Snap an object to a cell border via macro Brettjg Excel Discussion (Misc queries) 9 May 1st 07 02:10 PM
Place a Bottom Border in a Table via a Macro [email protected] Excel Discussion (Misc queries) 0 February 25th 07 11:19 PM
toggling jlofritts Excel Worksheet Functions 3 March 7th 06 06:34 PM


All times are GMT +1. The time now is 02:12 AM.

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"