+ Reply to Thread
Results 1 to 6 of 6

extract unique and common elements from cells

  1. #1
    Registered User
    Join Date
    09-09-2017
    Location
    canada
    MS-Off Ver
    07
    Posts
    4

    extract unique and common elements from cells

    Hi,
    I'd like to be able to compare two (or more) cells and extract unique and common characters between the cells.

    For example
    from

    cell A1: XYZ
    cell A2: XYR

    What I'd like is three different outputs:

    one with what is unique to A1 - in this case Z
    one with what is unique to A2 - in this case R
    and one with what is common to the cells - in this case XY

    thanks to the site I have been able to put commas between the characters making XYZ look like X,Y,Z which may make the problem easier.

    Hopefully someone can help - thanks a lot

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: extract unique and common elements from cells

    welcome to the forum
    VBA solution
    this works provided there are no duplicates as in your example

    Please Login or Register  to view this content.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: extract unique and common elements from cells

    This is untested. It works with your example. In B1 array enter this formula and fill down. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In C1 this non-array formula and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For the comma separated strings array enter this in F1 and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    then in G1 this non-array formula and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.




    A
    B
    C
    D
    E
    F
    G
    1
    XYZ
    Z
    XY
    X, Y, Z
    Z
    XY
    2
    XYR
    R
    XY
    X, Y, R
    R
    XY
    3
    Dave

  4. #4
    Registered User
    Join Date
    09-09-2017
    Location
    canada
    MS-Off Ver
    07
    Posts
    4

    Re: extract unique and common elements from cells

    Hello Kev - thank you
    I screwed up - have said the original data is in A1 and B1 - if I do a simple replacement of all A2 cells and change to B1 will that work?
    Also I'm very new to this - I've added modules as FUNCTIONS before - will this run the same way if so how do I run this?
    Thank you so very much

  5. #5
    Registered User
    Join Date
    09-09-2017
    Location
    canada
    MS-Off Ver
    07
    Posts
    4

    Re: extract unique and common elements from cells

    Hi I screwed up - meant A1 and B1 as original cells - couldn't get it to work by substituting
    Last edited by loup29; 09-19-2017 at 11:08 PM.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: extract unique and common elements from cells

    Try array entering this in C1 and filling down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    C
    1
    XYZ
    XYR
    Z
    2
    R

+ 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: 1
    Last Post: 08-24-2017, 04:56 AM
  2. [SOLVED] How to extract address elements
    By PK9 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 01-12-2017, 05:10 AM
  3. [SOLVED] Extract Unique Items (No VBA/No Helper Cells)
    By NeedForExcel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2015, 03:09 AM
  4. How to extract HTML elements?
    By babyboy808 in forum Excel General
    Replies: 1
    Last Post: 07-22-2014, 04:24 AM
  5. Extract common text strings between two cells A1 B1
    By ghost_chip in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-25-2013, 01:39 AM
  6. Compare two text cells and extract common text words
    By ghost_chip in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2012, 06:07 AM
  7. How to extract each pair of elements from a string?
    By zwieback89 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-12-2012, 04:17 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