+ Reply to Thread
Results 1 to 5 of 5

Compare ONLY text (no numbers) in 2 strings?

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Compare ONLY text (no numbers) in 2 strings?

    Hello... I have two strings that I'm comparing, but am getting a lot of failures because part of the strings are real time stock prices.
    I'd like to compare only the text aspects of the strings, if possible. Anybody know how?

    Example of two strings I'm comparing...

    This should PASS:
    STR1 = QUALCOMM INC (QCOM US) PRICE 50.84 D $ DELAYED
    STR2 = QUALCOMM INC (QCOM US) PRICE 50.81 D $ DELAYED

    This should FAIL:
    STR1 = QUALCOMM INC (QCOM US) PRICE 50.84 D $ DELAYED
    STR2 = QUALCOMM INC (QCOM US) PRICE 50.84 Y $ DELAYED

    Any idea how I can strip out the numeric values for a comparison?
    The text before/after will vary, as will the position within the string, so I can't think of a way to parse more appropriately.

    Thank you for any help!
    Last edited by JP Romano; 08-30-2011 at 02:00 PM. Reason: SOLVED

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Compare ONLY text (no numbers) in 2 strings?

    It looks like you're just examining just the ends of the text, so this will do that for you:
    [code]=RIGHT(A1,11)=RIGHT(A2,11)[/code
    assuming your comparison strings are in cells A1 and A2
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Compare ONLY text (no numbers) in 2 strings?

    Mr. Lafferty, thanks so much for the quick reply! Unfortunately, the position of the price can change, as can the text before or after, so I don't think looking at the right (or left) characters will quite do it. I actually had it set up to concatenate the left 10 and right 10 for each string, then compare those, but ran into problems with about 30% of my tests.
    I do appreciate your response though!

  4. #4
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Compare ONLY text (no numbers) in 2 strings?

    I got it!
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Compare ONLY text (no numbers) in 2 strings?

    If you wrote that as a function you could use it on worksheets in other formula, i.e.

    Please Login or Register  to view this content.

    Edited to add - If your strings are quite long the function would be more efficient if it just looped through the numbers 0-9, replacing each number in turn with a blank. That way it would always take 10 iterations to complete, rather than an iteration for each character of the string.
    Last edited by Andrew-R; 08-30-2011 at 02:20 PM.

+ 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