+ Reply to Thread
Results 1 to 10 of 10

Text comparison with VBA

  1. #1
    Registered User
    Join Date
    11-11-2013
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    11

    Question Text comparison with VBA

    Hi all and a happy new year,

    I am trying to compare 2 columns with many rows. I have tried to do it with conditional formatting but it is somehow not reliable. Now I am trying with VBA. What I want to do is this:

    I have a column (e.g A) with many rows, each row contains a sentence and I have a column (e.g B) each row contains a single word. Now what I want to do is to check if a row in A contains any words from B. If such a row has been found then it schould be colored. In column C should be written the words found separated with comma. All should be case insensitive. Something like this:

    Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: book
    once or twice she had peeped into the Book her sister was reading, but it had no pictures or conversations in it, peeped peeped, book
    `and what is the use of a book,' thought Alice `without pictures or conversation?' nice book

    I have tried with this code but it doesn't work (Am a newbie in VBA...)

    Please Login or Register  to view this content.
    What should the code look like if B is in another sheet?

    Thanks in advance.

    Regards

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Text comparison with VBA

    try
    Please Login or Register  to view this content.
    Last edited by jindon; 01-02-2014 at 10:05 AM. Reason: Missed "All should be case insensitive."

  3. #3
    Registered User
    Join Date
    11-11-2013
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Text comparison with VBA

    Great. Thank you very much for the quick respond and for the code.

    It works but it is case sensitive and it doen't color the row in A.

    What must I change If column B is in another sheet?
    Last edited by spreader; 01-02-2014 at 10:27 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Text comparison with VBA

    Then need to see your REAL desired result in a workbook.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Text comparison with VBA

    My guess..
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-11-2013
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Text comparison with VBA


  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Text comparison with VBA

    No Excel file, no help.

  8. #8
    Registered User
    Join Date
    11-11-2013
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Text comparison with VBA

    Here is the desired result in excel.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Text comparison with VBA

    Here's a file with the code.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-11-2013
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Text comparison with VBA

    That's exactly what I need.

    You are great. I love this forum. You saved my life twice.

    Thank you very much.

+ 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. [SOLVED] Text Clean up and Comparison
    By Winship in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-01-2013, 02:52 PM
  2. Text comparison problem
    By PamB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2013, 10:29 AM
  3. IF and text comparison issue
    By shelluk in forum Excel General
    Replies: 7
    Last Post: 08-19-2010, 11:00 AM
  4. Help with text comparison
    By kchandra in forum Excel General
    Replies: 4
    Last Post: 05-05-2010, 02:37 PM
  5. Text Comparison with Number
    By sglick in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-22-2007, 05:52 PM

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