+ Reply to Thread
Results 1 to 3 of 3

Update VBA code from cell shading to cell border

  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Update VBA code from cell shading to cell border

    Hi All
    My first time to post!! I've been working all day on this & cant figure it out Any help wld be MOST appreciated!! I have this macro that works perfectly:

    Sub HTH()
    Dim rFound As Range
    Dim lFirstRow As Long

    With Range("B:B")
    If [A1] = "" Then Exit Sub
    Set rFound = .Find([a1], LookIn:=xlValues)
    If Not rFound Is Nothing Then
    lFirstRow = rFound.Row
    Do
    Rows(rFound.Row).Columns("B:Q").Interior.ColorIndex = 6
    Set rFound = .FindNext(rFound)
    Loop While Not rFound Is Nothing And rFound.Row > lFirstRow
    End If
    End With

    End Sub


    I'd like to update it to remove the yellow shading (interior.colorindex=6) & add the below border on all sides of the row i.e. columns B:Q

    .LineStyle = xlDouble
    .Color = -6279056
    .TintAndShade = 0
    .Weight = xlThick


    I cant get it to work once I delete the shading code and try to add code for the bordering
    Thank you!!!

  2. #2
    Registered User
    Join Date
    05-22-2008
    Posts
    74

    Re: Update VBA code from cell shading to cell border

    Simply select the range then use the "Borders" to set the lines.
    Please Login or Register  to view this content.
    Scott
    The harder it gets the happier I am.
    Finally got my signature set up!

  3. #3
    Registered User
    Join Date
    02-07-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Update VBA code from cell shading to cell border

    This was the code i tried but it gives me the error "object doesnt support this property or method"???

    Sub HTH()
    Dim rFound As Range
    Dim lFirstRow As Long

    With Range("B:B")
    If [a1] = "" Then Exit Sub
    Set rFound = .Find([a1], LookIn:=xlValues)
    If Not rFound Is Nothing Then
    lFirstRow = rFound.Row
    Do
    Rows(rFound.Row).Columns ("B:Q")
    Range("B1:Q1").Select
    With Selection.borders(xlEdgeLeft)
    .LineStyle = xlDouble
    .ColorIndex = -6279056
    .TintAndShade = 0
    .Weight = xlThick
    End With
    With Selection.borders(xlEdgeTop)
    .LineStyle = xlDouble
    .ColorIndex = -6279056
    .TintAndShade = 0
    .Weight = xlThick
    End With
    With Selection.borders(xlEdgeBottom)
    .LineStyle = xlDouble
    .ColorIndex = -6279056
    .TintAndShade = 0
    .Weight = xlThick
    End With
    With Selection.borders(xlEdgeRight)
    .LineStyle = xlDouble
    .ColorIndex = -6279056
    .TintAndShade = 0
    .Weight = xlThick
    End With
    Set rFound = .FindNext(rFound)
    Loop While Not rFound Is Nothing And rFound.Row > lFirstRow
    End If
    End With

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Code: Cell Border
    By walid66 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-05-2010, 11:45 AM
  2. Code for Cell border styling
    By namz in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 06-03-2008, 01:47 AM
  3. Quick and Simple Cell Shading Code needed
    By DarrenH in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-21-2008, 10:26 PM
  4. [SOLVED] Conditional Cell Shading (based on the shading of other cells)
    By Tubby in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2006, 05:10 PM
  5. Replies: 0
    Last Post: 01-12-2005, 10:50 AM

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