ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Bottom border for each row code not working (https://www.excelbanter.com/excel-programming/393464-bottom-border-each-row-code-not-working.html)

Gwen

Bottom border for each row code not working
 
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

Gary Keramidas

Bottom border for each row code not working
 
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


--


Gary


"Gwen" wrote in message
...
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




Jim Thomlinson

Bottom border for each row code not working
 
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

--
HTH...

Jim Thomlinson


"Gwen" wrote:

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


Gwen

Bottom border for each row code not working
 
Works Perfectly
Thank all of you for your time and assistance.

"Jim Thomlinson" wrote:

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

--
HTH...

Jim Thomlinson


"Gwen" wrote:

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



All times are GMT +1. The time now is 02:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com