I am using the below macro to create borders on multiple sheets but it gives me a runtime error 1004 "unable to set the weight property of the border class". I thought if i removed them first it would fix the problem but it didn't. Any help would be appreciated...thanks..
Sub FormatBorders()
Application.ScreenUpdating = False
'On Error Resume Next
Dim wrkSheet As Worksheet
For Each wrkSheet In Sheets(Array("Sheet1", "sheet2", "sheet3"))
With wrkSheet
lastrow = .Range("c65536").End(xlUp).Row
For x = 2 To lastrow
Set rng = .Range("A" & x & ":r" & x)
With rng
.Borders.LineStyle = xlNone
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlInsideVertical).Weight = xlThin
End With
Next x
End With
Next wrkSheet
Application.ScreenUpdating = True
End Sub
Sub FormatBorders()
Application.ScreenUpdating = False
'On Error Resume Next
Dim wrkSheet As Worksheet
For Each wrkSheet In Sheets(Array("Sheet1", "sheet2", "sheet3"))
With wrkSheet
lastrow = .Range("c65536").End(xlUp).Row
For x = 2 To lastrow
Set rng = .Range("A" & x & ":r" & x)
With rng
.Borders.LineStyle = xlNone
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlInsideVertical).Weight = xlThin
End With
Next x
End With
Next wrkSheet
Application.ScreenUpdating = True
End Sub