+ Reply to Thread
Results 1 to 9 of 9

VBA to find and replace border colours

  1. #1
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    VBA to find and replace border colours

    Hi
    I want to have a code that will search through the active sheet only, find a cell border colour and replace it with another. Also change the thickness of the line to THIN
    the colours I want to replace are RGB(255,0,0) with RGB(191,191,191)
    I've tried to find some code, but had no luck so far, can anyone please help with this?

    thanks

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: VBA to find and replace border colours

    Will the cells with borders on them also have values/formulas in them? I'm not sure there's a way to look at cell borders of empty cells without looking at every single cell on the sheet, which obviously you don't want to do.

    But I hope someone can prove me wrong!
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: VBA to find and replace border colours

    yes, they've all got formulas in them and the number formats can be different too
    Also, the red borders can be around a group of cells, but only on the outsides, not internal and they can be different shapes too

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: VBA to find and replace border colours

    This was fun, first time I can remember working with borders in VBA. So thanks.

    There's a lot of looping here, but I didn't really see any other way to accomplish this. Maybe someone else has more elegant code.

    Also, I hope it you intention to turn all those red borders into borders that look like the default cell borders? Because that's what that replacement thin grey line looks like.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: VBA to find and replace border colours

    hi
    thanks for that, but it doesn't seem to do anything, the borders do not change at all...

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: VBA to find and replace border colours

    Post an example workbook then, because it works on my test sheet with the descriptions you've given.

  7. #7
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: VBA to find and replace border colours

    Hi I've cut a section out and attached, thanks
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: VBA to find and replace border colours

    yes, they've all got formulas in them
    Well, your example doesn't have formulas. Put a formula in a cell and the code will remove the borders. So... are you now saying the cells won't have formulas in them? What will be in them?

  9. #9
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: VBA to find and replace border colours

    sorry, I had just pasted values in that, didn't realise would change it
    I've tried it again in my main file and it seems to work now, not sure what changed, but thanks very much!!

+ 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. [SOLVED] Find and replace where contents a formula so can't be seen by Find and replace.
    By markDuffy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2015, 02:24 PM
  2. Replies: 16
    Last Post: 12-02-2014, 03:38 PM
  3. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  4. [SOLVED] Can't find colour editor or any more colours
    By Battletoads in forum Excel General
    Replies: 2
    Last Post: 08-16-2013, 09:52 AM
  5. [SOLVED] Find & Replace colours
    By gjjh25 in forum Excel General
    Replies: 6
    Last Post: 08-14-2013, 05:44 AM
  6. find in excel replace in word: find/replace text in text boxes and headers
    By dean.rogers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2012, 12:40 PM
  7. Excel will not change cell border colours
    By Gren in forum Excel General
    Replies: 0
    Last Post: 08-09-2005, 09:07 AM

Tags for this Thread

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