Consulting

Results 1 to 3 of 3

Thread: Solved: Border Trouble!

  1. #1
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location

    Solved: Border Trouble!

    I recorded a macro to add a border all around the last cell in column F. After Adjusting it (RN is the row number of the last nonblank cell), this is what I came up with:

    [vba]Sub Border()
    With Range("F" & RN)
    .borders(xlDiagonalDown).LineStyle = xlNone
    .borders(xlDiagonalUp).LineStyle = xlNone
    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
    End With
    End Sub[/vba] But it doesn't work. What am I doing wrong? This should be a fairly simple and straightforward step.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You neeed to pass the RN value to Border
    EG
    [VBA]
    Sub DoThings()
    Border 10
    End Sub

    Sub Border(RN As Long)
    With Range("F" & RN)
    .Borders(xlDiagonalDown).LineStyle = xlNone
    'etc.

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location
    I knew it was simple! Thanks for pointing that out

Posting Permissions

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