+ Reply to Thread
Results 1 to 20 of 20

How to find text in cell and change font color if found

  1. #1
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    How to find text in cell and change font color if found

    Hi,

    New to forum and Excel! And I have stumbled across a major problem...

    I have a long list of all available products in one cell (D2) and a column of bought products (B2-B2900).
    I need to find a way to look in D2 after the text that is in B2 (example "Loxa") and if the word Loxa is found I want Excel to change the font color of just that word in D2. See of attached file "workbook1".

    Is there any way to accomplish that?

    I have only tried the most basic functions like IF and FIND but I don't think that's going to cut it...

    I'm grateful for any kind of help or tips! Thank you for reading

    Regards,
    Caroline
    Attached Files Attached Files

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: How to find text in cell and change font color if found

    I am not sure I am getting it.

    Give an example of something that is found, and what would be coloured as a result.

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to find text in cell and change font color if found

    Few questions:

    1) Would Loxa be the only word in the cell or would there be other words? If there are other words, do you only want Loxa to be a different color or can all the words get the new color?

    2) Is the list delimited by commas? And do you want the whole list to get the same font color?

    3) Could you manually adjust one of the results in your example to show us what the results should look like?
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to find text in cell and change font color if found

    If I read you correctly, you will need VBa for this, formula/formatting can't change the font colour for part of a string.

    Is this what you are trying to do?
    Loxa Startbatteri 90AH

    If so is a macro is required, is that acceptable?

    Why use the very long string in D2, and not a list?

    Is this any use?
    Attached Files Attached Files
    Last edited by Marcol; 05-14-2012 at 09:29 AM. Reason: Added Attachment

  5. #5
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    I'm attaching the file again with weak (and maybe useless) information of what I want.

    I want to find the word "Loxa" in B2, in the long list in D2 that contains all products. When it finds the word, I want the word "Loxa" (in D2) to change font color from black to blue while the rest of the text remains black. I can't write =FIND("Loxa",D2) because I have to go through the entire B-column (2900 cells). The result should end up in C2 with the whole list from D2 where the only change is that one word (or product) has changed color.

    Does that make sense or am I just beging confusing? :/

    I'm sorry for the weak explanation.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    No, it should read Loxa Startbatteri 90AH. I just shortened it...

    I don't understand macro but if there is a solution with macro I'll take it and google som tutorials

    I need the long string for a variable data print job. The list will take up one page and the colored products are there to show what the company has bought before.
    Last edited by niraya; 05-14-2012 at 09:30 AM.

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to find text in cell and change font color if found

    So what you are after is:

    For each word/phrase in Cell D2 (since there will be many) seperated by commas do the following:

    1) Find the word in the product list (Column B)

    2) Copy the cell containing the word from column B to Column C (same row)

    3) Change the font color of only the word that is being searched.

    Are these steps correct?

    Edit: After reading latest post, then #3 should be:

    3) Change the cell's font color (all words in cell since only one product will be in each cell)
    Last edited by abousetta; 05-14-2012 at 09:31 AM.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to find text in cell and change font color if found

    See the attachment I added to post #4

  9. #9
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to find text in cell and change font color if found

    Nice Marcol... didn't even see your attachment. You get a cookie, I mean am star

  10. #10
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    I'm sorry, that is not quite what I was after.

    I've made a "fake" workbook (see attached file) where you can see how the results should look. For this purpose I shortened the list in D2 to only the first 7 products.


    /Caroline
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to find text in cell and change font color if found

    Caroline, that's what I was afraid of. You are in luck though. I do have a personalized code that does this. It took me a year to research and test it but it should do what you are after. It's part of a much larger project so I will have to personalize it for your purposes. Hopefully I will get a chance to work on this later in the evening after work.

  12. #12
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: How to find text in cell and change font color if found

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    Oh my God, that sounds amazing, abousetta!

  14. #14
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to find text in cell and change font color if found

    OK Bob beat me to the soluton. You get a star too Bob.

    It seems I'm really slow on the draw today. Off to work then.

  15. #15
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    Wow, Bob, that looks complicated, haha. I'm going to test that right away! Thank you very much.

  16. #16
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    I ran the code but it differ a little from what I need:

    See my attachment for an example of the code result and my example (where, again, the list is shorter than the original). When searching in B2 it should only change that word (Loxa Startbatteri 90AH) and not all the words that's in the B2-list , and when it goes down to B3 it should only change that word (Loxa Startbatteri 110Ah) and so on.

    I think it shows in the file what I mean, but just for clarification; I don't mean that the words in B2 should be red, that part of the code was correct.


    Regards,
    Caroline
    Attached Files Attached Files

  17. #17
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: How to find text in cell and change font color if found

    You've totally lost me now, I am not clear as to whether you want to highlight the values in an existing list, or to create the list. If the former, why does your example list look different to the original list? If the latter, where do all of those values come from?

    Don't you just love it when the OP gives you an example to start with that is nothing like the real data?

  18. #18
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    I'm sorry about the confusion.
    I shortened the list so it would be easier to read. I remade it with the original data in this attachment. I want to generate a list from D2 where certain words are colored according to what
    text is in B2-B2900. This list should stretch from C2-C2900 or any other column.

    Maybe this new example can clarify things better...
    Attached Files Attached Files

  19. #19
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to find text in cell and change font color if found

    I really think that you are going about this the hard way.
    What are you trying to achieve?

    Trying to read a red group of products in a string of 8786 characters, is futile, Excel can't display that amount of characters.
    So how are you going to find and see "Filter Vxllåda", your last product in your string?

    See this workbook

    Conditional formatting
    Blue is found in list
    Red is not found in list

    Why can't you work with this?
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  20. #20
    Registered User
    Join Date
    05-14-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to find text in cell and change font color if found

    I know I'm making it very difficult for myself, even more so now that I hear everybody else saying the it's hard to pull off =)
    I have tried conditional formatting and it doesn't work for what I'm trying to do. The thing is, it doesn't matter that I can't read all the products in the long list, since am going to upload the whole sheet to XMPie and generate a variable print, where I will be able to see the whole list.
    But, as you pointed out, this seems to be the hard way so I'm going to try and find a different solution.

    Thank you for all your help!

+ 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