+ Reply to Thread
Results 1 to 6 of 6

BorderAround for Range (lastRow)

Hybrid View

  1. #1
    Registered User
    Join Date
    04-29-2015
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    82

    BorderAround for Range (lastRow)

    Hi guys,

    I'm hoping you can help, currently I'm using the below but I know it could be made a shorter code:

    Cells(LastRow + 1, 1).BorderAround Weight:=xlThin
    The above code is part of a user form which copies and pastes data into the next available line in my sheet. However, I want it to also add the border formatting from Column index 1 - 53. I'm sure there's a way that I don't have to use 53 lines of code to get this to work?

    Many thanks for your time.
    Last edited by Quasis; 11-06-2015 at 02:55 PM.

  2. #2
    Registered User
    Join Date
    04-29-2015
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: BorderAround for Range (lastRow)

    Solved my own issue:

    Range(Cells(LastRow + 1, 1), Cells(LastRow + 1, 53)).Borders.LineStyle = xlContinuous

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,082

    Re: BorderAround for Range (lastRow)

    Not sure what you are trying to do:

    Const LastRow As Long = 10
    Cells(LastRow + 1, 1).BorderAround Weight:=xlThin
    
    Dim lLR As Long
    lLR = Cells(Rows.Count, 1).End(xlUp).Row
    Cells(lLR + 1, 1).BorderAround Weight:=xlThin

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: BorderAround for Range (lastRow)

    Rows(LastRow + 1).Resize(, 53).Borders.Weight = xlThin
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,082

    Re: BorderAround for Range (lastRow)

    Sorry, misunderstood:

    Const LastRow As Long = 10
    Range(Cells(LastRow + 1, 1), Cells(LastRow + 1, 53)).BorderAround Weight:=xlThin
    
    Dim lLR As Long
    lLR = Cells(Rows.Count, 1).End(xlUp).Row
    Range(Cells(lLR + 1, 1), Cells(lLR + 1, 53)).BorderAround Weight:=xlThin

  6. #6
    Registered User
    Join Date
    04-29-2015
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: BorderAround for Range (lastRow)

    Appreciate your help guys but I solved it with:

    Range(Cells(LastRow + 1, 1), Cells(LastRow + 1, 53)).Borders.LineStyle = xlContinuous
    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] If # > 0 in $D4 then $A4 thru $D4 BorderAround
    By klotzy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-27-2015, 10:43 AM
  2. [SOLVED] Changing range in VBA to lastrow
    By BlakeSkate in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2015, 05:01 PM
  3. [SOLVED] How to select Range A1 to LastRow/LastColumn
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-29-2014, 03:40 AM
  4. Creating a table with VBA using lastrow as range
    By washout in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2013, 12:20 PM
  5. Copy From LastRow to LastRow+7
    By dvent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2010, 06:56 AM
  6. Copy from named range down until lastrow?
    By jazbath in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-19-2007, 05:56 PM
  7. [SOLVED] BorderAround method failure
    By johnhildreth@citynet.net in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2005, 02:50 PM

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