Emmily
Well-known Member
- Joined
- Oct 5, 2008
- Messages
- 676
Hi can someone please explain why i am get the below error on
.LineStyle = xlContinuous
Run-Time error 1004
Unable to set the LineStyle property of the border class
.LineStyle = xlContinuous
Run-Time error 1004
Unable to set the LineStyle property of the border class
Code:
Private Sub Borders()
Dim LastRow As Long
Dim Rng As Range
Dim ShtSummary As Excel.Worksheet
Dim myBorders() As Variant, item As Variant
myBorders = Array(xlEdgeLeft, _
xlEdgeTop, _
xlEdgeBottom, _
xlEdgeRight, _
xlInsideVertical, _
xlInsideHorizontal)
For Each item In myBorders
Set ShtSummary = Sheets(gstrSummary)
With ShtSummary
With .Range("A5:D5").Borders(item)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set Rng = .Range("A6:D" & LastRow)
With Rng.Borders(item)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 0
End With
End With
Next item
End Sub