ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error with Borders of a Range (https://www.excelbanter.com/excel-programming/421058-error-borders-range.html)

RyanH

Error with Borders of a Range
 

I am trying to draw borders around the columns in the ranges below. For some
reason I am getting an Error indicated below: "Unable to set the weight
property of the Border Class". This makes no sense to me because the code
before it works fine but it keeps getting hung up on the line indicated
below. Any ideas?

' adds border to quote sheet and product information
With .Range("B" & ActiveCell.Row, "H" & ActiveCell.Row + 28)
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
End With

With .Range("C" & ActiveCell.Row, "G" & ActiveCell.Row + 28)
.Borders(xlEdgeLeft).Weight = xlThin
ERROR .Borders(xlEdgeRight).Weight = xlThin
End With

With .Range("F" & ActiveCell.Row, "F" & ActiveCell.Row + 28)
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
End With
--
Cheers,
Ryan

Bernie Deitrick

Error with Borders of a Range
 
Ryan,

Your code works fine for me.

HTH,
Bernie
MS Excel MVP


"RyanH" wrote in message
...
I am trying to draw borders around the columns in the ranges below. For some
reason I am getting an Error indicated below: "Unable to set the weight
property of the Border Class". This makes no sense to me because the code
before it works fine but it keeps getting hung up on the line indicated
below. Any ideas?

' adds border to quote sheet and product information
With .Range("B" & ActiveCell.Row, "H" & ActiveCell.Row + 28)
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
End With

With .Range("C" & ActiveCell.Row, "G" & ActiveCell.Row + 28)
.Borders(xlEdgeLeft).Weight = xlThin
ERROR .Borders(xlEdgeRight).Weight = xlThin
End With

With .Range("F" & ActiveCell.Row, "F" & ActiveCell.Row + 28)
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
End With
--
Cheers,
Ryan





All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com