+ Reply to Thread
Results 1 to 4 of 4

VBA to compare two text strings and display diffeence

  1. #1
    Registered User
    Join Date
    06-25-2015
    Location
    Virginia
    MS-Off Ver
    2010
    Posts
    5

    VBA to compare two text strings and display diffeence

    Hello all!

    I am new to this forum and to VBA. I know that what I need to do will require VBA but I am not familiar with writing scripts.

    Here is an example of what I am working with and what I need to happen:

    A1 = ABDE
    B1 = ABCDEFGHIJ

    The result in C1 should be the difference between the two cells:
    C1 = CFGHIJ

    I have seen a lot of posts that have VBA scripts that will highlight what is different or display what is the same. I need the result to just be what is deifferent between the two cells.

    Thanks for any help!

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to compare two text strings and display diffeence

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-25-2015
    Location
    Virginia
    MS-Off Ver
    2010
    Posts
    5

    Re: VBA to compare two text strings and display diffeence

    Thaks for the quick reply!

    I do have more that I need to do with this. I didn't give enough info initially.
    Last edited by Me_in_va; 06-25-2015 at 02:48 PM.

  4. #4
    Registered User
    Join Date
    06-25-2015
    Location
    Virginia
    MS-Off Ver
    2010
    Posts
    5

    Re: VBA to compare two text strings and display diffeence

    The code you posted in your reply works great for just one row. I need something to work on many rows.

    The worksheet I am working in is called "Required Monthly Courses"

    On "Required Monthly Courses" here is what I am working with:
    Col A = Names (starts in row 9 and goes down many rows...)
    Col C through L = Courses 1 through 10 (Pass / Fail result explained below)
    Col N = Results of all courses concatenated from columns C through L (letters only, no numbers. Again, explained below)
    Col T through AC = Course scores (Actual percent values 0% through 100%)

    What it is doing:
    I import a report of the course scores starting in cell P5 through AC?? (names are in col Q and reformatted to First name Last Name in Col A). The scores in columns T through AC are put through a formula in columns C through L and given a letter for each course that received a passing score and a zero for a failing score. Courses that have not been taken are left blank.

    Course 1 = A, Course 2 = B, Course 3 = C, etc...

    So
    A5 = John
    C5 = A
    D5 = B
    E5 = 0
    F5 = BLANK
    G5 = BLANK
    H5 = BLANK
    N5 = AB

    A6 = Bob
    C6 = 0
    D6 = B
    E6 = C
    F6 = 0
    G6 = E
    H6 = F
    N6 = BCEF

    A7 = Sue
    C7 = A
    D7 = B
    E7 = C
    F7 = 0
    G7 = E
    H7 = 0
    N7 = ABCE

    O3 = ABCDEF (A text string that is the result of a CONCATENATE fumction that puts all the courses letters available for the available courses. The how of this cell is not important, the cell reference is.)

    I would need Column O to display the courses not taken and the courses that were not passed:
    O5 = CDEF
    O6 = AD
    O7 = DF

    So John has taken courses 1, 2 and 3 but only passed 1 and 2 (Courses A, B and C taken, Courses A and B passed, Course 3 = 0 because he did not receive a passing score). Cell N5 displays AB (passed A & B, C through F are omitted)
    Bob has taken courses 1 through 6 (A through F but only passed Courses B, C, E and F). Cell N6 displays BCEF as he did not pass A and D.

    I need a way to display the difference between column N and cell O3 to be displayed in column O for each name.

    Columns T through AC are just scores and I have the formulas worked out to give the results I need in Columns C through L as well as for cell O3. I jus tneed help getting Column O to display the difference between the text strings in Column N and cell O3.

    All the cell references are the same as the actual workbook I am working in.

    HTML is OFF for me right now so I can't post a sample table. I know it would probably make things a lot easier.

    Thaks for any help! (Again.)

+ 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. Replies: 6
    Last Post: 02-28-2013, 11:27 AM
  2. [SOLVED] Compare text strings easily
    By Yoc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-28-2012, 01:26 AM
  3. Compare ONLY text (no numbers) in 2 strings?
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2011, 02:16 PM
  4. Replies: 1
    Last Post: 10-18-2010, 06:32 PM
  5. [SOLVED] Compare cells/columns and highlight matching text strings
    By luxbelle in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-25-2005, 06:06 PM

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