Bottom border for each row code not working

G

Gwen

I would like a bottom border For each row on the sheet from columns a:l
For some reason this code does not work.
What am I missing?

Dim x As Integer
Dim lastrow As Long

lastrow = Range("A65536").End(xlUp).Row

For x = 7 To lastrow
ActiveCell.Columns("A:L").Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone

With Selection.Borders(xlEdgeBottom)

.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone

next x


Thanks
 
G

Gary Keramidas

is all you want a bottom border from in columns a:L from row 7 to the lastrow?

Sub test()
Dim x As Integer
Dim lastrow As Long
lastrow = Range("A65536").End(xlUp).Row
For x = 7 To lastrow
With Range("A" & x).Resize(1, 12).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

Next x

End Sub
 
J

Jim Thomlinson

Give this a whirl...

Dim rng As Range

Set rng = Range(cells(Rows.Count, "A").End(xlUp), Range("L7"))
rng.Borders.LineStyle = xlNone
rng.Borders(xlInsideHorizontal).LineStyle = xlContinuous
rng.Borders(xlEdgeBottom).LineStyle = xlContinuous
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top