+ Reply to Thread
Results 1 to 11 of 11

Highlight Cell If Macro

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Highlight Cell If Macro

    I want to look at Column D on the sheet 'Furniture' from row 2 down as far as the last used data in row 2 and if the the cell contains the word "Multi" then I want it to highlight the cell in light red.

  2. #2
    Forum Contributor
    Join Date
    05-29-2013
    Location
    MD
    MS-Off Ver
    Excel 365
    Posts
    148

    Re: Highlight Cell If Macro

    Use conditional formatting on column D? Or do you need to only perform this up to last used data?

    Regards
    Duncan

  3. #3
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Highlight Cell If Macro

    Conditional formatting will not work as my data is dirty and gets changed every day so therefore cells get inserted and deleted and this alters the conditional formatting. I need a macro that is used whenever the sheet is opened and this solves my issue.

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Highlight Cell If Macro

    This is some quick and dirty code. Let me know if it helps.

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Highlight Cell If Macro

    Mhmm, doesn't quite do the trick. Is there a different way of coding it as I'm sure we don't need to use InStr here.

  6. #6
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Highlight Cell If Macro

    Any particular reason you'd rather not use InStr?

    This following method use a filter instead. Let me know if it works

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Highlight Cell If Macro

    Don;t want to use InStr as I will need to add a couple of words to it. In total, there will be up to 6 different words that if contained in the cell I'll want to highlight red. If this can be achieved using InStr then I will be happily proven wrong

  8. #8
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Highlight Cell If Macro

    Gotcha. Use the second code I gave you, (the one with the filter) and change criteria1 to the following:

    Please Login or Register  to view this content.
    Replace the XXXX with the values you want to search.

    Let me know if this helps

  9. #9
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Highlight Cell If Macro

    Sorry to be a pain again, but I don't want to use a filter as this macro I need will go in amongst many other macros which will have the data very messy and running a filter would cause quite a delay/non-responsiveness. Is there a loop or something like I've been playing below with that would work:

    The below highlights what I want if the date is today. Can it be altered for what I want above?
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    05-29-2013
    Location
    MD
    MS-Off Ver
    Excel 365
    Posts
    148

    Re: Highlight Cell If Macro

    Expanding on BigBas' idea:

    We can total the InStr result for each word (stored in an array) and then if the total > 0, change the cell color. The idea being that if one or more of the words is found, total will be greater than 0.

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Highlight Cell If Macro

    I don't want to use a filter as this macro I need will go in amongst many other macros which will have the data very messy and running a filter would cause quite a delay/non-responsiveness. Is there a loop or something like I've been playing below with that would work:
    1st of all try the code in post #10

    But what I am interested in is why you think running a filter even multiple times would have the effect below
    running a filter would cause quite a delay/non-responsiveness
    more than a loop?
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

+ Reply to Thread

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