+ Reply to Thread
Results 1 to 15 of 15

How can excel ignore certain text when it searches for text?

  1. #1
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    How can excel ignore certain text when it searches for text?

    Hello,

    I have two excel documents in the same workbook... what I wanted to know was, how can I search one document for John Smith where the other document has him listed now as "John Smith attorney"?

    I only need to know that John Smith is on the other sheet, if excel searched for him, it will tell me that he's not there because "attorney" is making the code think that it's a totally different name.

    Here's the macro:

    Please Login or Register  to view this content.

    Every time I search the two ranges between the two sheets, it shows me the blue highlight for a name that technically is in the other sheet - in reality it's only a different thing added to the name (Mr, atty, Mrs, etc.). How do I get this VBA code to ignore certain words in a cell so that the code knows to ignore certain words?


    Thanks!


    Thank you much!
    JB
    Last edited by Leith Ross; 05-15-2011 at 04:16 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How can excel ignore certain text when it searches for text?

    Hello JB,

    You need to Change this line ...
    Please Login or Register  to view this content.

    To this...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    BLESS YOU SIR !!!!!!!!!

    I have been looking for this answer for MONTHS!!!!!

    Thank you, thank you!!!!!!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How can excel ignore certain text when it searches for text?

    Hello JB,

    Glad to help. Hard to believe it you months to get an answer to this problem.

  5. #5
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    Hello again,

    I just have one last question... I noticed that if another guy named John Smith is in the sheet, the code will ignore both and not tell me that "John #1" (or #2) is in there. Is there anything I can do about this?

    Thanks again!
    JB

    ADDENDUM:

    Maybe it might be possible to state whatever words you want excel to ignore? ("Attorney", "Mr", "Street", etc.)
    Last edited by jonathynblythe; 05-16-2011 at 05:23 PM.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How can excel ignore certain text when it searches for text?

    Hello JB,

    It would be easier to answer your questions with a sample workbook that uses some actual data. Seeing before and after examples of what you want to do will speed up the code development and provide you with the results you want more quickly.

  7. #7
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    Here's a sample of the workbook:


    This is one of the two sheets in the workbook. The one you're looking at now is for the 2010 year, the other sheet (not pictured, but the same format as you see with this sheet) is for the 2011 year.

    As you can see from the code posted in the beginning of this thread, that Glaswegian from techsupportforum dot com made for me, it allows you to select the range for one column on the first sheet in the workbook, and then to select a second range on the second worksheet. I first start with the phone number column "F" for range one, then I go to the other sheet and select column "F" for it's phone numbers. The code compares them and if it can't find the phone number on this years sheet, it highlights the phone number cell on the 2010 sheet blue.

    Here's the problem, when it does this for the name and or addresses, it will tell me that "John Smith" is not on there, when he really is since he's now "John Smith Attorney". You showed me how to wild card the results, and it did work for me... however, when there are two of the same addresses on the 2011 sheet, it seems to skip over it and move on to the next address on the 2010 sheet. Does this make sense?

    Thank you much
    JB
    Last edited by Leith Ross; 05-17-2011 at 12:32 AM. Reason: Removed jpg attachment due to privacy concerns

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How can excel ignore certain text when it searches for text?

    Hello JB,

    Due to the personal nature of the data, I removed your attachment. If you can save a single sheet to a new workbook and email it to me then I can create the macro and post it here for others to see. Is that doable?

  9. #9
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    Well actually, I was just wondering if it's possible to just make sure that the addresses don't get missed when there's more than one of the same throughout the sheet. I don't know what your email is and I'm not able to send you the workbook due to the information, unfortunately. Sorry....

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How can excel ignore certain text when it searches for text?

    Dive into the VBEditor's help (F1)

    Scrutinize the method 'find'
    Study the parameter xlPart & xlWhole.



  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How can excel ignore certain text when it searches for text?

    Hello jonaythnblythe,

    I sent my email address to you by private message.

  12. #12
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    Ok, It's done. Thanks again!

  13. #13
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    Actually maybe I do have one more question... is there anyway excel can compare two documents where "John Smith" and "Mr John Smith" (the same exact guy) - where afterwards it highlights the "Mr" red with colorindex=3 (or font.colorindex=3) somehow to show that this is now what's different as opposed to highlighting the entire cell red with colorindex=3?

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How can excel ignore certain text when it searches for text?

    Hello jonathynblythe,

    It is doable. It may slow things down a bit. I'll work on making those changes to the macro.

  15. #15
    Registered User
    Join Date
    04-06-2011
    Location
    Dover, DE
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: How can excel ignore certain text when it searches for text?

    Wow, you're assembling a whole new macro just for me?? How can I thank you for all this?

+ 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