Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro - Clear Borders

Give this a whirl...

sub test
Range("A1:B50").Borders.LineStyle = xlNone
end sub
--
HTH...

Jim Thomlinson


"Finance Guru" wrote:

Hi All,

I know how to clear the contents of cells in a macro,ie.
Range("A1:B50").ClearContents - however can anyone tell me what needs to be
included in a macro to clear "Borders" created around cells for a given range.

I am just getting into creating macros - so if the above is not clear,please
let me know.
Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Macro - Clear Borders

To account for diagonals revise to this.

Sub test()
With Range("A1:B50")
.Borders.LineStyle = xlNone
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With
End Sub


Gord Dibben MS Excel MVP

On Wed, 21 Nov 2007 10:15:02 -0800, Jim Thomlinson
wrote:

Give this a whirl...

sub test
Range("A1:B50").Borders.LineStyle = xlNone
end sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro - Clear Borders

And I just learned something new. I did not realize that my original code did
not remove the diagonals. That being said I can honestly say I have never
used the diagonals... but if I ever do... Thanks Gord
--
HTH...

Jim Thomlinson


"Gord Dibben" wrote:

To account for diagonals revise to this.

Sub test()
With Range("A1:B50")
.Borders.LineStyle = xlNone
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With
End Sub


Gord Dibben MS Excel MVP

On Wed, 21 Nov 2007 10:15:02 -0800, Jim Thomlinson
wrote:

Give this a whirl...

sub test
Range("A1:B50").Borders.LineStyle = xlNone
end sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Macro - Clear Borders

Not only doesn't it remove diagonals, it adds diagonals to cells in the range
that don't originally have them.

Set A1:B10 with cell borders and include diagonals.

Run your original macro.

Clears the outside and interior borders in A1:B10 but leaves the diagonals and
also adds them to A11:B50

Note: the diagonals are actually doubled up so if you go to FormatCellBorders
you have to click twice to clear them.

Not nice and definitely weird<g


Gord

On Wed, 21 Nov 2007 11:54:04 -0800, Jim Thomlinson
wrote:

And I just learned something new. I did not realize that my original code did
not remove the diagonals. That being said I can honestly say I have never
used the diagonals... but if I ever do... Thanks Gord


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro - Clear Borders

Spookey... This one darn near fits into JWalk's XL oddities.

This has re-affirmed my desire to just never use diagonals. That being said
many moons from now I am going to break down and use them for some obscure
reason and my code will mess them up. On that day I will (vaguely) recall
this conversation with a sense of (told you so)...
--
HTH...

Jim Thomlinson


"Gord Dibben" wrote:

Not only doesn't it remove diagonals, it adds diagonals to cells in the range
that don't originally have them.

Set A1:B10 with cell borders and include diagonals.

Run your original macro.

Clears the outside and interior borders in A1:B10 but leaves the diagonals and
also adds them to A11:B50

Note: the diagonals are actually doubled up so if you go to FormatCellBorders
you have to click twice to clear them.

Not nice and definitely weird<g


Gord

On Wed, 21 Nov 2007 11:54:04 -0800, Jim Thomlinson
wrote:

And I just learned something new. I did not realize that my original code did
not remove the diagonals. That being said I can honestly say I have never
used the diagonals... but if I ever do... Thanks Gord



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
Clear cell borders for blank white page TJAC Excel Discussion (Misc queries) 2 February 21st 07 02:32 PM
Clear cell borders for blank white page john Excel Discussion (Misc queries) 0 February 21st 07 01:53 PM
Clear all borders with VBA Otto Moehrbach Excel Programming 2 December 22nd 06 07:36 PM
A MACRO TO BUILD BORDERS lar48ry Excel Programming 5 January 27th 05 01:53 PM
Using a macro to add borders Colin Foster[_3_] Excel Programming 1 October 19th 04 07:14 PM


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

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

About Us

"It's about Microsoft Excel"