+ Reply to Thread
Results 1 to 4 of 4

Range Offset for Creating Borders

Hybrid View

  1. #1
    Registered User
    Join Date
    12-06-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Excel 2007
    Posts
    13

    Range Offset for Creating Borders

    Hello,

    I am looking to write a macro and can't get it just right.

    If I select a range from AO7 - AO12 I would like to be able to run the macro and have it put a thick black border around A7-T12. So I want it to take whatever range I select which will always be in the AO column and put a thick black border around those same rows but just columns A-T. I select AO2-AO3, run macro, A2-T3 has thick border.

    Thanks so much.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Range Offset for Creating Borders

    Maybe:

    Sub cheesiepoof05()
    
    
    Range(Selection.Offset(, -40), Selection.Offset(, -21).Resize(Selection.Rows.Count)).Select
            Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        
    
    
    End Sub

  3. #3
    Registered User
    Join Date
    12-06-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Range Offset for Creating Borders

    That worked perfectly. Thank you very much!

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Range Offset for Creating Borders

    You're welcome. I'm glad that it works for you, and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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