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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
It works! Thanks for your help.

-Agnes

Norman Jones said:
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 said:
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
 
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
 
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

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
 

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

Back
Top