Results 1 to 14 of 14

Creating Dynamic Range Borders

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Creating Dynamic Range Borders

    I am looking to create a border based on a dynamic range. A list is generated from a data validation in cell E2 of a worksheet. The information begins populating in cell "A4":"E4" and down based open the item chosen in the data validation. I would like the information when it is populated to be bordered. I have found a couple macros but can not seem to get any of them to work properly. So far this is the one I have been working with.


    Application.ScreenUpdating=False
    For Each cell In Range("A4", Range("A65536").End(xlUp)) 
        If cell.value >"" Then 
         
        With Range(cell, cell.Offset(0, 4)) 
             
            With .Borders(xlEdgeLeft) 
                .LineStyle = xlContinuous 
                .Weight = xlThin 
                .ColorIndex = xlAutomatic 
            End With 
            With .Borders(xlEdgeTop) 
                .LineStyle = xlContinuous 
                .Weight = xlThin 
                .ColorIndex = xlAutomatic 
            End With 
            With .Borders(xlEdgeBottom) 
                .LineStyle = xlContinuous 
                .Weight = xlThin 
                .ColorIndex = xlAutomatic 
            End With 
            With .Borders(xlEdgeRight) 
                .LineStyle = xlContinuous 
                .Weight = xlThin 
                .ColorIndex = xlAutomatic 
            End With 
            With .Borders(xlInsideVertical) 
                .LineStyle = xlContinuous 
                .Weight = xlThin 
                .ColorIndex = xlAutomatic 
            End With 
             '    With .Borders(xlInsideHorizontal)
             '        .LineStyle = xlContinuous
             '        .Weight = xlThin
             '        .ColorIndex = xlAutomatic
             '    End With
        End With 
    End If 
            Application.ScreenUpdating=True 
    
    
    Next
    It works creates borders but not in the desired spots. From cell A4:E4 and below based upon the entered information. I think this might be because it does not update with the data validation.


    Moderator Edit:
    @ jaredmccullough

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.
    Last edited by Cutter; 09-07-2012 at 08:13 PM. Reason: Added code tags

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