+ Reply to Thread
Results 1 to 19 of 19

Find and highlight/bold/underline/colour a block of matching text (is this possible?)

  1. #1
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Find and highlight/bold/underline/colour a block of matching text (is this possible?)

    Hi,

    I would like to create a macro that will search words in Column A against Column B for text, and once found, will highlight the match in column B. Is this possible?

    As it is easier to show an example, I have created an example of what I'm trying to do. Please kindly refer to the example and guide me along.. Thank you very much!
    Attached Files Attached Files
    Last edited by joelhuang; 06-10-2011 at 03:33 AM.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    No example attached

    Have you tried Conditional Formatting ?

  3. #3
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Hello, what a coincidence, I was just amending the example when you replied

    Yes, I tried it but I can't possibly do it for every cell...

  4. #4
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Hi, could someone please give me some assistance here? Thank you...

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Hello Joelhuang,

    If you are using this formula in conditional formatting, this will highlight the whole cell, not the particular word. if you want to highligh or Bold the words, would require VBA, hope some one will get to you.

    Select the range, B5:B10, then try this formula in CF,

    Please Login or Register  to view this content.
    Choose the format.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Thumbs up Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Andy that was amazing! I tried reading the book for dummies and only had a rough idea, but to put it to work is totally different! Thank you~

  8. #8
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Thanks too Haseeb :D

  9. #9
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Hi, is this enhancement possible?

    instead of highlighting only the second column, the matches are highlighted in both columns while the script is searching for matches (example attached).

    Thanks for any help!
    Attached Files Attached Files

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Again, thanks!

  12. #12
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Just for knowledge's sake, is it possible to indicate which 2 columns to compare, so that I can do it directly on the data and don't have to copy them onto another workbook and paste in Column A and B?
    Very curious about the usage of relative reference, but it always confuses me..

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    If you select the first column of the table then you can use
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    I see... So if I were to select, say, Column B and G, this will work as well to compare Column B against Column G?

  15. #15
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Selection of columns B and G would be a non contiguous selection and require the use of the Areas object.

    try this (untested),

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    Hello Andy,

    It's me again...

    It seems that duplicate words in the second columns will only be highlighted once, while those in the first column are always highlighted even if they are duplicated words. I'd need to highlight all words including duplicates, so is there a way to go about it?

    Eg.
    Raw Data
    Column A_____________________________________Column B
    Ma Tai Tai from China loves to drink Tai Tai Soup_____Ma Tai Tai in Japan hates the smell of Tai Tai Soup

    Desired outcome
    Column A_____________________________________Column B
    Ma Tai Tai from China loves to drink Tai Tai Soup_____Ma Tai Tai in Japan hates the smell of Tai Tai Soup

    Actual Results
    Column A_____________________________________Column B
    Ma Tai Tai from China loves to drink Tai Tai Soup_____Ma Tai Tai in Japan hates the smell of Tai Tai Soup

  17. #17
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    You need to loop rather than do the code once.

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    So brilliant! Thank you :D

    How about this: it is best to keep it to scan for A1-A10, as it will take too much time and memory to run for A10000 all the time. However, the number of data ranges from A500 to A1000.

    Can I do this to make it semi-automatic?

    eg.

    1) I will do a check to see what is the last cell of Column A that contains data.

    Please Login or Register  to view this content.
    2) The code will then be:
    Please Login or Register  to view this content.
    May I know if this is possible too? I tried reading vba for dummies, but don't think I saw the method of detecting the last cell being taught..

    Currently, I have the following as a temporary measure:
    Please Login or Register  to view this content.
    Last edited by joelhuang; 08-02-2011 at 03:26 AM.

  19. #19
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Find and highlight/bold/underline/colour a block of matching text (is this possib

    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)

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