+ Reply to Thread
Results 1 to 4 of 4

Can You Output Differences Among Strings?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-10-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Question Can You Output Differences Among Strings?

    I am seeking to determine the value differences between two strings. For example if I had the following two entries:

    MicrosoftExcelRocks
    MicrosoftExcelAlwaysRocksNow

    I want to be able to pull only the difference between the two entries, which are the characters "AlwaysNow"

    Does anyone know how to go about doing this?

    Thanks for any help!

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Can You Output Differences Among Strings?

    As you describe it, it would be a fairly simple macro; however, what if the entries are reversed? Would

    MicrosoftExcelAlwaysRocksNow
    MicrosoftExcelRocks

    provide the same output, or would it be blank?

    what would you expect from

    abcabcxabc
    xx

    Pauley

  3. #3
    Registered User
    Join Date
    11-10-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Can You Output Differences Among Strings?

    Quote Originally Posted by Pauleyb View Post
    As you describe it, it would be a fairly simple macro; however, what if the entries are reversed? Would

    MicrosoftExcelAlwaysRocksNow
    MicrosoftExcelRocks

    provide the same output, or would it be blank?

    what would you expect from

    abcabcxabc
    xx

    Pauley
    I see what your saying. But could I sidestep the first question by saying that the order does not matter since I could create a new column and reverse the order that I look at the two entries?

    I am not sure how to set up this macro. Do you have any suggestions?

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Can You Output Differences Among Strings?

    The simplest method would be to go character by character and then track when they don't match. Something like (pseudo-code)

    i = j = 1
    holdstr=""
    do
     if str(i) = str(j) then 
      i=i+1 
      j=j+1
     else
      holdstr=holdstr&str(i)
      i=i+1
     endif
    until end of str1 or end of str 2
    Pauley

+ 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