Clear borders macro not working in Excel 2007 but works fine in 20

R

RyanH

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
 
J

Jim Rech

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

--
Jim
| 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
 
B

Bernard Liengme

Your macro worked just fine for me.
Try it with a new workbook
best wishes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top