This seems like it would be straight-forward but I'm struggling. I have a program that makes several tables (and that works). What I can't seem to do is apply 'All Borders' to each table it creates. The code that I added that doesn't work is:
Range(.ListObjects(i)).Select
With Selection.Borders
.LineStyle = x1Continuous
.Weight = x1Thin
.ColorIndex = x1Automatic
End With
my attempted code that doesn't work. (I've tried many different things with no success).
Any help would be appreciated!
Range(.ListObjects(i)).Select
With Selection.Borders
.LineStyle = x1Continuous
.Weight = x1Thin
.ColorIndex = x1Automatic
End With
my attempted code that doesn't work. (I've tried many different things with no success).
Any help would be appreciated!
VBA Code:
Sub CreateTables()
Dim lr As Long, i As Integer
Dim cll As Range, rng As Range
With ActiveSheet
lr = .Cells(Rows.Count, "B").End(xlUp).Row '<-- changed to column B
Set rng = .Range("B1:B" & lr)
For Each cll In rng
If cll.Value = "Check Item" Then 'find header row
i = i + 1
.ListObjects.Add(xlSrcRange, .Range(cll, cll.End(xlDown).Offset(, 9)), , xlYes).Name = cll.Offset(-1, -1).Value
.ListObjects(i).TableStyle = "" 'Use blank format for table
.ListObjects(i).DataBodyRange.AutoFilter 'Remove dropdown arrows for each column in table
Range(.ListObjects(i)).Select
With Selection.Borders
.LineStyle = x1Continuous
.Weight = x1Thin
.ColorIndex = x1Automatic
End With
End If
Next cll
End With
End Sub