+ Reply to Thread
Results 1 to 12 of 12

Change colour of 3 cells if 1 cell has a certain word

  1. #1
    Registered User
    Join Date
    05-11-2019
    Location
    Leicester, England
    MS-Off Ver
    Office 365
    Posts
    52

    Change colour of 3 cells if 1 cell has a certain word

    hi ppl

    i have 4 rows a b c and d, in row d if i enter "network issues rack 4" in cell d3 i want it to recognise ive entered the word "rack" in that cell and cells a3 b3 c3 and d3 all turn red.
    so if i enter "network issues switch 2" i want it to recognise "switch" and the cells to turn orange.

    TIA
    Martin

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Change colour of 3 cells if 1 cell has a certain word

    Here is a worksheet change event

    Please Login or Register  to view this content.
    Open the VBE (Alt +F11)
    In the left window, double click on your worksheet name
    In the right window that opens paste in the code from above
    Close each window and save
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-11-2019
    Location
    Leicester, England
    MS-Off Ver
    Office 365
    Posts
    52

    Re: Change colour of 3 cells if 1 cell has a certain word

    That's great, works perfectly however I have many rows, up to HH would I do this for every 4th row or is there something that could be added to the above to make this happen?

    Thank you for your help

    Martin

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Change colour of 3 cells if 1 cell has a certain word

    Not understanding. Suggest you post a file and explain. This only works for changes to Column D. So please be more specific in your explanation as to what you want. To much detail with VBA is not a bad thing.

  5. #5
    Registered User
    Join Date
    05-11-2019
    Location
    Leicester, England
    MS-Off Ver
    Office 365
    Posts
    52

    Re: Change colour of 3 cells if 1 cell has a certain word

    I have attached a example of what the document looks like, I hope this helps, currently I have conditional formatting set to turn the columns green when something is entered under the engineer column then with the code I need I want that to change when those words are entered into the Notes column.
    Attached Files Attached Files

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Change colour of 3 cells if 1 cell has a certain word

    you have posted a blank worksheet. You mention that you have columns going out to HH? True? Not shown in this scenario. Also you mention data in every fourth row. Also True? Again no data showing. A sample worksheet with dummy data that is representative of your actual worksheet really would make this easier to understand your needs. A before and after scenario. I cannot see what is on your screen so you have to be able to show me because I also cannot read your mind and your explanation is to general to extrapolate a solution.

  7. #7
    Registered User
    Join Date
    05-11-2019
    Location
    Leicester, England
    MS-Off Ver
    Office 365
    Posts
    52

    Re: Change colour of 3 cells if 1 cell has a certain word

    Sorry I thought giving a little information would work but I get the complexity of it I should have included everything 1st so here goes.

    I have set everything up how my document looks , ive hidden columns A-G as they are not important and have confidential information so I can not include.

    Currently when I enter a name in the engineer column - that column plus the site, location and notes column turns green.
    Empty rows are black then when something is entered into the notes column it turns yellow.

    I would like to slightly change things so if the word "rack" is written in the notes column I want it to go red and orange if the word "switch" is written. if something else is written not including those words I want it to go yellow. and stay green if it is blank.

    I have put an example in the second sheet of what it should look like

    TIA
    Martin
    Attached Files Attached Files

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Change colour of 3 cells if 1 cell has a certain word

    Give this code a try. You have a bit of work to complete it as I only included the first three columns of your scenario for where the Notes are.
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Change colour of 3 cells if 1 cell has a certain word

    Without knowing the full scope, could you look at using a table with conditional formatting? I've structured the data so it's usable in a table and added the conditional formatting so it works as you ask. Take a look and let us know if this works for you? (I put the table in columns A-E and put conditional formatting in for if it found "switch" or "rack". The other colors are there only from previous conditional formatting.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-11-2019
    Location
    Leicester, England
    MS-Off Ver
    Office 365
    Posts
    52

    Re: Change colour of 3 cells if 1 cell has a certain word

    Thank you both for you help, Gregb11 I never designed the document so I cant change what it already looks like as it is already in use. alansidman yours kind of works however it only formats the 1 cell not the 3 cells before it I need all four cells to change colour when the text is entered.

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Change colour of 3 cells if 1 cell has a certain word

    Changed the formatting rows. See code below

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Change colour of 3 cells if 1 cell has a certain word

    "I never designed the document so I cant change what it already looks like as it is already in use."
    I understand. However, I would challenge that heavily. Using a table gives you so many more benefits than the design you currently have and I expect people would welcome a better design. But, I don't know the history or full requirements so who knows - good luck with it.

+ 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. Change the colour of single word in text string based on another cell value
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-03-2014, 09:41 AM
  2. Macro to change colour of cell based on finding a specific word in the cell
    By Shelby761 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 09:46 AM
  3. Change colour of cells based on another cell's colour (Not value)
    By LTrain89 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-25-2013, 08:44 PM
  4. Change Colour of 3 Cells based on Value of Other Cell
    By hazza147 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2010, 05:57 AM
  5. VB Code to change cell colour by entering a word
    By Twaddy in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-24-2010, 07:38 AM
  6. Change colour of cells based a cell?
    By smogsy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-05-2010, 09:22 AM
  7. Replies: 7
    Last Post: 11-27-2008, 10:31 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