+ Reply to Thread
Results 1 to 15 of 15

need button that will highlight cells with 26 or 48 in them

  1. #1
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    need button that will highlight cells with 26 or 48 in them

    I'm trying to get a code that will check a few columns to see if the cells contain 26 or 48 in them and if they do then highlight the cells. I can do this with conditional format but the conditional formatting gets erased each time i put new data in the cells (i have another code that ports in the values). Here is an example of what I want to see but i cant figure out how to make the code to check it. I'm only looking at columns L, V and AF from row 5 to 28. all the other data does not need to be checked.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: need button that will highlight cells with 26 or 48 in them

    Use a helper column of formulas that checks L, V, and AF from each row, then filter on that column of formulas: they won't be affected by your new data.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: need button that will highlight cells with 26 or 48 in them

    Hi Kevinu,

    How to you put new data in?
    You could just past value so you conditional formating is not effected?

    Give it a try it might just be that easy

    Grtz

  4. #4
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: need button that will highlight cells with 26 or 48 in them

    Added command button to worksheet and attached the following code:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: need button that will highlight cells with 26 or 48 in them

    i use coding like this on 3 seperate sheets to get data on this sheet
    Please Login or Register  to view this content.
    the conditional formatting on the other sheets gets copied to this sheet, which erases anything on this sheet.

  6. #6
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: need button that will highlight cells with 26 or 48 in them

    I found this:

    Sheet1.Cells(7, 4).Copy
    Sheet1.Cells(7, 10).PasteSpecial Paste:=xlPasteValues

    and that does the trick

  7. #7
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: need button that will highlight cells with 26 or 48 in them

    i tried paste and it has other weird side affects. The code above worked great. I forgot to mention, is there now a way to check if any of the cells are colored then it stops or exits the code. I want to put this code in front of another one that exports all this data to yet another sheet so it will stop if there are any cells with 26 or 48 in them.

    Bernie, I think your suggestion would work well too... have a helper cell and if its value is positive then the code exits. Ill try that.

  8. #8
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: need button that will highlight cells with 26 or 48 in them

    If it's automated (macro), why check to see if any cells are colored rather than just checking to see if those cells have a 26 or 48 in them?

  9. #9
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: need button that will highlight cells with 26 or 48 in them

    I want the user to see where they are so they can correct the data then rerun the export code. So it doesnt need to check for color if checking for values is easier, it just also needs to inform the user where the errors are.

  10. #10
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: need button that will highlight cells with 26 or 48 in them

    tried to use this but doesnt work

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: need button that will highlight cells with 26 or 48 in them

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: need button that will highlight cells with 26 or 48 in them

    unfortunately it doesnt recognize the interior color. Did some googling and apparently its almost impossible to detect a conditional formatted cells color. I got it to work with a helper cell but would love to have it detect conditional formatted color


    used this
    Please Login or Register  to view this content.
    and this in helper cells

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  13. #13
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: need button that will highlight cells with 26 or 48 in them

    Sorry - I should have noticed that you are using CF:


    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: need button that will highlight cells with 26 or 48 in them

    Sorry - not paying enough attention to realize that you were using CF:


    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: need button that will highlight cells with 26 or 48 in them

    Rather than using Conditional Formatting to color the cells per my original code (post #4), you could instead use normal cell formatting. This would allow you to check the cell's interior color, etc.
    Please Login or Register  to view this content.

+ 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. Highlight Button
    By simonplus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2016, 11:25 AM
  2. make an activex command button highlight
    By c_spooner1999 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2013, 12:57 PM
  3. Replies: 2
    Last Post: 10-24-2012, 11:47 AM
  4. VBA button to highlight row then move up and copy next row, etc
    By simpleonline1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2011, 08:10 AM
  5. [SOLVED] Highlight the contain of textbox and radio button
    By Peter Cheang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2006, 11:55 AM
  6. using option button to highlight cells
    By Carl in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-05-2006, 01:55 PM
  7. [SOLVED] Highlight cells with ctrl-click but only un-highlight one cell
    By hagan in forum Excel General
    Replies: 5
    Last Post: 05-27-2005, 02:05 PM

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