Reputation: 679
Receiving an error with this segment of code. I am using code from Excel 2010 worksheet, where it works without issue, on an Excel 2013 computer. All of my libraries have updated correctly and we are not sure why this does not seem to be forward compatible.
With Me.Range("T3:Y196")
.borders(xlEdgeBottom).Weight = xlThick
.borders(xlEdgeLeft).Weight = xlThick
.borders(xlEdgeRight).Weight = xlThick '<--- error here
.borders(xlEdgeTop).Weight = xlThick '<--- once above code is commented out error occurs here
End With
Also receiving an error here:
With Range(ConvertColumnNumberToLetter(questionTextCol - 1) & CStr(myRow) & ":" & ConvertColumnNumberToLetter(instructionsCol) & CStr(myRow)).borders(xlEdgeTop)
'above Range gives same result as "T3:Y196" but I hard coded it to do some testing in the previous With Statement
.LineStyle = xlContinuous '<--- Error
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium '<--- Error
End With
Now, both .LineStyle
and .Weight
work in other areas of the code so we are not sure what to do about this.
When I record a macro I get this:
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
When I add the range in it works to perfection (again this is on a clean sheet):
With Range("C2:I20")
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeRight).Weight = xlMedium
.Borders(xlEdgeLeft).Weight = xlMedium
.Borders(xlEdgeTop).Weight = xlThick
End With
Any assistance would be greatly appreciated. Thanks!
Upvotes: 4
Views: 900
Reputation: 1585
I don't know if this will help but instead of using with Me.Range try setting a sheet object and working from there. I tend to get less glitching this way. example
Dim TheSheet as Worksheet
Set TheSheet = Sheets("Your Sheet Name")
With TheSheet.Range("T3:Y196")
.borders(xlEdgeBottom).Weight = xlThick
.borders(xlEdgeLeft).Weight = xlThick
.borders(xlEdgeRight).Weight = xlThick '<--- error here
.borders(xlEdgeTop).Weight = xlThick
End With
The only other thing I can think of is merged cell issues, where half the cell is in the set range, and half the cell is not.
Upvotes: 1