Results 1 to 5 of 5

VBA: how to remove borders

This is a discussion on VBA: how to remove borders within the Excel Questions forums, part of the Question Forums category; Hey all, trying to find a way to remove borders with the cells i have selected. Code so far: Code: ...

  1. #1
    Board Regular
    Join Date
    Apr 2008
    Location
    Sydney, Australia.
    Posts
    257

    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
    410

    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 2003, Windows XP

  3. #3
    Board Regular
    Join Date
    Apr 2008
    Location
    Sydney, Australia.
    Posts
    257

    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

    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

    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!

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