+ Reply to Thread
Results 1 to 5 of 5

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

  1. #1
    AGnes
    Guest

    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

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    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

  3. #3
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >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




  4. #4
    AGnes
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > >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

    >
    >
    >


  5. #5
    Robert McCurdy
    Guest

    Re: 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" <[email protected]> wrote in message news:[email protected]...
    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



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1