VBA: how to remove borders

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: VBA: how to remove borders

  1. #1
    Board Regular
    Join Date
    Apr 2008
    Location
    Sydney, Australia.
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA: how to remove borders

     
    Hey all, trying to find a way to remove borders with the cells i have selected. Code so far:

    Code:
        Worksheets("Agent Summary").range("A6:AA" & xlLastRow("Agent Summary") + 5).Select
        Selection.ClearContents
        Selection.Orientation = 0
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        Selection.Borders(xlEdgeLeft).LineStyle = xlNone
        Selection.Borders(xlEdgeTop).LineStyle = xlNone
        Selection.Borders(xlEdgeBottom).LineStyle = xlNone
        Selection.Borders(xlEdgeRight).LineStyle = xlNone
        Selection.Interior.ColorIndex = xlNone
        Selection.Font.Bold = False

    But it's not working. Thanks in advance.

  2. #2
    Board Regular sbeatton's Avatar
    Join Date
    May 2004
    Posts
    411
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA: how to remove borders

    You haven't defined xlLastRow. Refer to http://www.vbaexpress.com/kb/getarticle.php?kb_id=417 for an example.
    Excel 2010

  3. #3
    Board Regular
    Join Date
    Apr 2008
    Location
    Sydney, Australia.
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA: how to remove borders

    Sorry, xlLastRow() is a function that I have borrowed from the URL you mentioned. It returns the appropriate number for my purposes.

  4. #4
    MrExcel MVP
    Join Date
    Aug 2004
    Location
    Tokyo, Japan
    Posts
    16,995
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA: how to remove borders

    Code:
    Worksheets("Agent Summary").range("A6:AA" & xlLastRow("Agent Summary") + 5).Clear
    ?

  5. #5
    Board Regular
    Join Date
    Apr 2008
    Location
    Sydney, Australia.
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA: how to remove borders

      
    Jindon, thank you so much matey, I knew there was a statement that would return a cell back to its default!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com