Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Clear borders macro not working in Excel 2007 but works fine in 20

For some reason when I run this macro in Excel 2003 it works just fine. But
when I try to run it in Excel 2007 I get an Error indicated below. Anyone
have any ideas why?

Sub ClearRange ()

'clears all borders
With Range("B" & ActiveCell.Row, "H" & ActiveCell.Row + 30)
Error = .Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Clear borders macro not working in Excel 2007 but works fine in 20

Works here. Worksheet isn't protected, etc.?

--
Jim
"RyanH" wrote in message
...
| For some reason when I run this macro in Excel 2003 it works just fine.
But
| when I try to run it in Excel 2007 I get an Error indicated below. Anyone
| have any ideas why?
|
| Sub ClearRange ()
|
| 'clears all borders
| With Range("B" & ActiveCell.Row, "H" & ActiveCell.Row + 30)
| Error = .Borders(xlDiagonalDown).LineStyle = xlNone
| .Borders(xlDiagonalUp).LineStyle = xlNone
| .Borders(xlEdgeLeft).LineStyle = xlNone
| .Borders(xlEdgeTop).LineStyle = xlNone
| .Borders(xlEdgeBottom).LineStyle = xlNone
| .Borders(xlEdgeRight).LineStyle = xlNone
| .Borders(xlInsideVertical).LineStyle = xlNone
| .Borders(xlInsideHorizontal).LineStyle = xlNone
| End With
|
| End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Clear borders macro not working in Excel 2007 but works fine in 20

Your macro worked just fine for me.
Try it with a new workbook
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"RyanH" wrote in message
...
For some reason when I run this macro in Excel 2003 it works just fine.
But
when I try to run it in Excel 2007 I get an Error indicated below. Anyone
have any ideas why?

Sub ClearRange ()

'clears all borders
With Range("B" & ActiveCell.Row, "H" & ActiveCell.Row + 30)
Error = .Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
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
VBA errors in 2007 (works fine in 2003) Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 14 September 6th 09 12:46 PM
xls file works fine in Excel 2000 and 2007 but crashes on opening in 2003 gromit12 Excel Discussion (Misc queries) 2 November 6th 07 09:30 PM
XValues series breaks on disjoint ranges - but works fine in Excel 2007 [email protected] Excel Programming 5 October 2nd 07 12:02 AM
Macro hangs up often but sometimes works fine Jeff Excel Worksheet Functions 3 June 13th 06 01:01 PM
Macro works fine on PC; fails on Mac marlea[_16_] Excel Programming 1 March 20th 06 08:26 PM


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