+ Reply to Thread
Results 1 to 7 of 7

Find and replace multiple values based on criteria

  1. #1
    Registered User
    Join Date
    01-01-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    6

    Find and replace multiple values based on criteria

    Hi

    I have a column of 600+ values (English football positions) and would like to find and replace them based on some criteria. An example spreadsheet is attached. Example.xlsx

    The column is something like:

    Position
    FW
    FW
    GK
    M(C)
    M(C)
    D(C)
    M(CLR),FW
    AM(CL),FW
    FW
    D(R),DM(C)
    M(CL)
    D(CR)
    DM(C),M(L)
    M(CL)
    ....

    The criteria I have is that any value with "M" (i.e. M(C), M(CL), DM(C)) should be replaced by "MF". Any value with "D" (i.e. D(R), D(C)) should be replaced with "DF".
    [Note here, that DM(C) contains both "D" and "M" but "M" condition to take priority]
    FW remains as FW.
    GK remains as GK.
    For cells with two values, both values should be replaced based on the criteria and remain separated by a comma.
    E.g. D(R), DM(C) should be replaced by DF,MF
    But, if the two values overlap, they should be replaced by just one.
    E.g. DM(C),M(L) should be replaced by MF

    This is a bit out of my league. Is there any easy way to do this?

    Thank you

  2. #2
    Forum Contributor
    Join Date
    09-07-2013
    Location
    chennai
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Find and replace multiple values based on criteria

    Hi Samuelhzb,
    Just filter the criteria which you have in "position "coloum. and manually we can change this easily.find the attachment .
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-02-2015
    Location
    NW Washington
    MS-Off Ver
    2007, 2010, mac 2011
    Posts
    10

    Re: Find and replace multiple values based on criteria

    You might want to split POSITION into two columns first by selecting column F and using DATA-TOOLS-Text To Columns. Use a comma delimiter. In column H use this formula:

    =IF(LEFT(F2,1)="M",REPLACE(F2,1,1,"MF"),IF(LEFT(F2,1)="D",REPLACE(F2,1,1,"DF"),F2))

    Copy the formula to column I as well. You can concatenate the columns after this process if it's important for you to keep all the info in one cell rather than multiple cells for each position.

  4. #4
    Registered User
    Join Date
    01-02-2015
    Location
    NW Washington
    MS-Off Ver
    2007, 2010, mac 2011
    Posts
    10

    Re: Find and replace multiple values based on criteria

    After looking at your other criteria I think this formula might actually be more accurate.

    IF(LEFT(F2,1)="M",REPLACE(F2,1,8,"MF"),IF(LEFT(F2,1)="D",REPLACE(F2,1,8,"DF"),F2))

    Initially I thought you only wanted to replace the M or F while keeping the remainder of the text.

  5. #5
    Registered User
    Join Date
    01-01-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    6

    Re: Find and replace multiple values based on criteria

    Hi Bob,

    Your formula works well except for values like AM(LR) and AM(RLC) which I would like to convert to MF too (since it contains a M).
    There does not seem to be a way to work round your formula for this?

    And Concatenate will work if values for the two columns are different. But if the values in the two columns are the same (e.g. MF and MF), how can I make it to recognise that and return MF instead of MF,MF?

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Find and replace multiple values based on criteria

    Maybe this will suit your needs.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Registered User
    Join Date
    01-02-2015
    Location
    NW Washington
    MS-Off Ver
    2007, 2010, mac 2011
    Posts
    10

    Re: Find and replace multiple values based on criteria

    Maybe in column H…

    =IF(OR(LEFT(F2,1)="M",LEFT(F2,2)="AM"),REPLACE(F2,1,8,"MF"),IF(LEFT(F2,1)="D",REPLACE(F2,1,8,"DF"),F2))

    then in column I

    =IF(OR(LEFT(G2,1)="M",LEFT(G2,2)="AM"),REPLACE(G2,1,8,"MF"),IF(LEFT(G2,1)="D",REPLACE(G2,1,8,"DF"),""))

    Concatinate in J

    =IF(OR(H2=I2,I2=0),H2,IF(I2<>"",CONCATENATE(H2,", ",I2),H2))

    Also looks like newdovermans solution works

+ 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. Criteria based find and replace
    By doubl3d80 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2014, 12:19 PM
  2. [SOLVED] Find blank cell and replace based on criteria
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-27-2012, 05:36 AM

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