ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cells(Rows.Count, "b").End(xlUp).Row (https://www.excelbanter.com/excel-programming/362375-cells-rows-count-b-end-xlup-row.html)

Kate[_2_]

Cells(Rows.Count, "b").End(xlUp).Row
 
So, you can use the formula in the subject line (Cells(Rows.Count,
"b").End(xlUp).Row) to select the last cell in the column. But, I have
a table with a variable number of rows, which will most likely be
empty.

So instead of selecting the last cell with a value in it, I want to
select hte last cell with a border around it.

How?

Thanks


Ikaabod[_91_]

Cells(Rows.Count, "b").End(xlUp).Row
 

Will this work for you?

Sub LastBorder()
Dim myCell As String
Range("B:B").Select '<===You can change this to whatever range you
want
For Each cell In Selection
If cell.Borders(xlEdgeBottom).LineStyle = xlNone Then
GoTo fin
End If
myCell = cell.Address
Next cell
fin:
If myCell < "" Then
Range(myCell).Select
Else
Range("B1").Select
End If
End Sub


--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=545352



All times are GMT +1. The time now is 04:21 PM.

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