+ Reply to Thread
Results 1 to 10 of 10

Loop Macro to Auto Format Borders

Hybrid View

  1. #1
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: Loop Macro to Auto Format Borders

    For many of the simple tasks, it is easy to record a macro when we manualy do it first. Then you can re-run the macro with the necessary changes. This is what I did for your requirement. See the code
    Sub Macro2()
        Range("A1:F1").Select
        Range(Selection, Selection.End(xlDown)).Select
     '  Selection.Borders(xlDiagonalDown).LineStyle = xlNone
     '  Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
    '       .ColorIndex = xlAutomatic
    '        .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
    '       .ColorIndex = xlAutomatic
    '       .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
    '       .ColorIndex = xlAutomatic
    '       .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
    '       .ColorIndex = xlAutomatic
    '       .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
     '      .ColorIndex = xlAutomatic
     '      .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
    '       .ColorIndex = xlAutomatic
    '       .TintAndShade = 0
            .Weight = xlThin
        End With
    End Sub
    rgds

    johnjohns

  2. #2
    Registered User
    Join Date
    08-19-2010
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Loop Macro to Auto Format Borders

    Thanks for the quick response. I did learn some from this post but I can't figure out how to modify the code to work for my application. I forgot to mention that cells A1-D1 through A#-D# are blank so I want to loop until column E is blank. Columns E and F will always contain data and end on the same row. Thanks

+ 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