Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Remove borders in range

Hi,

I am trying to clear any cells having borders within a range of their top
and bottom borders. I have the following code:

Sub TroubleTktsClear()

With shtTroubleTickets.Range("B5:B6000")
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
End With

With shtTroubleTickets.Range("A4:B6000")
.ClearContents
End With

End Sub

The contents are clearing but the borders are not clearing. As you can see,
I have tried it with xlNone and xlLineStyleNone and neither is working. I
have checked enableevents is true as is screenupdating.

Have I missed something?

--
Thanks for your help.
Karen53
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Remove borders in range

Do you mean you want to clear all horizontal borders, if so include the
following

On Error Resume Next
.Borders(xlInsideHorizontal).LineStyle = xlNone
On Error GoTo 0

Unless you know the range will have at least two rows the line will error,
hence on error resume next (similarly for inside vertical borders)

xlNone and xlLineStyleNone return the same constant, -4142

ClearContents does not remove formats, use ClearFormats or Clear to remove
contents and formats

Regards,
Peter T


"Karen53" wrote in message
...
Hi,

I am trying to clear any cells having borders within a range of their top
and bottom borders. I have the following code:

Sub TroubleTktsClear()

With shtTroubleTickets.Range("B5:B6000")
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
End With

With shtTroubleTickets.Range("A4:B6000")
.ClearContents
End With

End Sub

The contents are clearing but the borders are not clearing. As you can

see,
I have tried it with xlNone and xlLineStyleNone and neither is working. I
have checked enableevents is true as is screenupdating.

Have I missed something?

--
Thanks for your help.
Karen53



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Remove borders in range

Thank you, Peter!
--
Thanks for your help.
Karen53


"Peter T" wrote:

Do you mean you want to clear all horizontal borders, if so include the
following

On Error Resume Next
.Borders(xlInsideHorizontal).LineStyle = xlNone
On Error GoTo 0

Unless you know the range will have at least two rows the line will error,
hence on error resume next (similarly for inside vertical borders)

xlNone and xlLineStyleNone return the same constant, -4142

ClearContents does not remove formats, use ClearFormats or Clear to remove
contents and formats

Regards,
Peter T


"Karen53" wrote in message
...
Hi,

I am trying to clear any cells having borders within a range of their top
and bottom borders. I have the following code:

Sub TroubleTktsClear()

With shtTroubleTickets.Range("B5:B6000")
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
End With

With shtTroubleTickets.Range("A4:B6000")
.ClearContents
End With

End Sub

The contents are clearing but the borders are not clearing. As you can

see,
I have tried it with xlNone and xlLineStyleNone and neither is working. I
have checked enableevents is true as is screenupdating.

Have I missed something?

--
Thanks for your help.
Karen53




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
Borders for range Neil Pearce Excel Discussion (Misc queries) 0 April 8th 08 11:58 AM
Bug applying Borders to Range Bart[_6_] Excel Programming 1 January 4th 08 03:26 PM
how do you remove borders DD Excel Discussion (Misc queries) 4 February 23rd 07 06:37 AM
How to remove borders in a range of cells? DORI Excel Programming 17 December 9th 05 02:45 AM
Remove all borders from a range quartz[_2_] Excel Programming 4 September 20th 05 02:16 AM


All times are GMT +1. The time now is 10:45 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"