ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find last row, add "Total" in col B & border (https://www.excelbanter.com/excel-programming/331493-find-last-row-add-total-col-b-border.html)

AGnes

find last row, add "Total" in col B & border
 
I want to find the last row in a worksheet, then add the text "Total" under
column B, and add a border from column C thru O:

..Borders(xlEdgeBottom)
..LineStyle = xlDouble

How can I select the range?

-Agnes

Norman Jones

find last row, add "Total" in col B & border
 
Hi AGnes,

Try:

Sub Tester()
Dim LRow As Long
Dim Rng As Range

LRow = _
Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Cells(LRow + 1, "B").Value = "Total"
Set Rng = Range(Cells(LRow + 1, "C"), _
Cells(LRow + 1, "O"))

With Rng.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.ColorIndex = xlAutomatic
End With
End Sub

---
Regards,
Norman



"AGnes" wrote in message
...
I want to find the last row in a worksheet, then add the text "Total" under
column B, and add a border from column C thru O:

.Borders(xlEdgeBottom)
.LineStyle = xlDouble

How can I select the range?

-Agnes




AGnes

find last row, add "Total" in col B & border
 
It works! Thanks for your help.

-Agnes

"Norman Jones" wrote:

Hi AGnes,

Try:

Sub Tester()
Dim LRow As Long
Dim Rng As Range

LRow = _
Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Cells(LRow + 1, "B").Value = "Total"
Set Rng = Range(Cells(LRow + 1, "C"), _
Cells(LRow + 1, "O"))

With Rng.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.ColorIndex = xlAutomatic
End With
End Sub

---
Regards,
Norman



"AGnes" wrote in message
...
I want to find the last row in a worksheet, then add the text "Total" under
column B, and add a border from column C thru O:

.Borders(xlEdgeBottom)
.LineStyle = xlDouble

How can I select the range?

-Agnes





Leith Ross[_26_]

find last row, add "Total" in col B & border
 

Hello Agnes,

The folowing code will help you select the range you want.

Dim LastRow As Long
Dim BlankRow As Long

LastRow = Range("B" & Rows.Count).End(xlUp).Row
BlankRow = LastRow + 1

Cells(BlankRow, "B").Value = "Total"

With Range(Cells(BlankRow, "C"), Cells(BlankRow, "O"))
..Select
..Borders(xlEdgeBottom)
..LineStyle = xlDouble
End With

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=378246


Robert McCurdy[_3_]

find last row, add "Total" in col B & border
 
How is this?

With [B65536].End(xlUp).Offset(1, 0)
.Value = "Total"
.Offset(0, 1).Resize(1, 13).Borders(xlEdgeBottom).Color = RGB(255, 0, 0)
.Offset(0, 1).Resize(1, 13).Borders.LineStyle = xlDouble
End With


Regards
Robert McCurdy

"AGnes" wrote in message ...
I want to find the last row in a worksheet, then add the text "Total" under
column B, and add a border from column C thru O:

..Borders(xlEdgeBottom)
..LineStyle = xlDouble

How can I select the range?

-Agnes




All times are GMT +1. The time now is 09:50 AM.

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