ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Select Syntax (https://www.excelbanter.com/excel-programming/416573-range-select-syntax.html)

u473

Range Select Syntax
 
I need to select LastRow, Columns L through N to draw a double line
before my Total row.
But, because my LastRow varies, my Range Select cannot be hard coded.
What is the proper Range Select Syntax to say something like
Range("L:N" & LastRow).select ?
..
LastRow = Range("L65000").End(xlUp).Row
Range("L23:N23").Select ' Range syntax to be corrected for variable
LastRow.
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Color = -3407872
.TintAndShade = 0
.Weight = xlThick
End With
..
Help appreciated,
J.P.

JLGWhiz

Range Select Syntax
 
Once you have established the last row:

LastRow = Range("L65000").End(xlUp).Row

Then you can use that as your row reference in the range to create the
double line border.

With Range("L" & LastRow & ":N" & LastRow).Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Color = -3407872
.TintAndShade = 0
.Weight = xlThick
End Wotj

You do not have to select it.
"u473" wrote:

I need to select LastRow, Columns L through N to draw a double line
before my Total row.
But, because my LastRow varies, my Range Select cannot be hard coded.
What is the proper Range Select Syntax to say something like
Range("L:N" & LastRow).select ?
..
LastRow = Range("L65000").End(xlUp).Row
Range("L23:N23").Select ' Range syntax to be corrected for variable
LastRow.
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Color = -3407872
.TintAndShade = 0
.Weight = xlThick
End With
..
Help appreciated,
J.P.


Jim Thomlinson

Range Select Syntax
 
No need to actually select the range... Try this...

Dim rng As Range

Set rng = Cells(Rows.Count, "L").End(xlUp).Resize(1, 3)
With rng.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Color = -3407872
.TintAndShade = 0
.Weight = xlThick
End With

--
HTH...

Jim Thomlinson


"u473" wrote:

I need to select LastRow, Columns L through N to draw a double line
before my Total row.
But, because my LastRow varies, my Range Select cannot be hard coded.
What is the proper Range Select Syntax to say something like
Range("L:N" & LastRow).select ?
..
LastRow = Range("L65000").End(xlUp).Row
Range("L23:N23").Select ' Range syntax to be corrected for variable
LastRow.
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Color = -3407872
.TintAndShade = 0
.Weight = xlThick
End With
..
Help appreciated,
J.P.


u473

Range Select Syntax
 
Woo !!! Simple but much appreciated. Thank you both.
J.P.


All times are GMT +1. The time now is 03:01 PM.

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