+ Reply to Thread
Results 1 to 9 of 9

Find & Replace data with multiple If range

  1. #1
    Registered User
    Join Date
    08-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    26

    Find & Replace data with multiple If range

    Hi there,

    I was wondering if anyone could help me in scripting the code for solution of my problem.
    say that i have alist of data in "A2:A", which are a string file (text)
    and i want to rename each data to a certain name that defined in
    range "B1:B2" (String file too).

    For Example: for range
    C2 = S16e
    C3 = 16/E
    C4 = 18W
    C5 = Site18 w

    & The target name is to be:
    B1=16E
    B2=18W

    For case above, i need to replace C2&C3 in to 16E, while C4&C5 to be 18W.

    I really appreciate for your time & help,
    Miners
    Last edited by miners; 10-28-2009 at 11:22 PM.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Find & Replace data with multiple If range

    Hi,

    It looks as if the function SUBSTITUTE() would solve your problem ...

    HTH

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find & Replace data with multiple If range

    Hi miners
    You would be better served if you attached a dummy file showing what you have and what you would like it to be (before and after) as your post is somewhat confusing. You refer to
    alist of data in "A2:A",
    and yet your "sample data"
    For Example: for range
    C2 = S16e
    C3 = 16/E
    C4 = 18W
    C5 = Site18 w
    refers to something entirely different such that I can't readily tell for certain what you're looking for.
    I'd be glad to look at the issue with more information. John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Registered User
    Join Date
    08-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Find & Replace data with multiple If range

    Thanks for the response jaslake&JeanRage,

    you're right there's a mistake in the example given, for the sample data, instead of C2:C5, they should be in range A2:A5.

    I have attached the dummy : before the substitution & after the substitution, which match the target name.

    The inconsistency in the data are sometime they have lower/uppercase, space, slash, etc. But they would have the correct number & letter (i.e 16, E, 18, W).

    Thanks for your time
    Miners
    Attached Files Attached Files

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find & Replace data with multiple If range

    Hi miners
    Try the attached. It's been tested on your sample data and appears to work.
    Hope this helps. John
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Find & Replace data with multiple If range

    Hi Thanks jaslake,

    that's very cool, it works as i wanted verywell. However it seems the formula working on replacing based on 5 criterias:
    space, slash,uppercase,lowercase,"-"
    I was wondering if i add another criteria such as:
    "AB" on sample data and it'll need to be replaced as "ABC"
    what change need to be made in the code?
    i guess that also would make the code more flexible to accomodate any new sample data ID in the future(?)

    really appreciate your help & time
    Rgds,
    Miners

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find & Replace data with multiple If range

    Hi miners
    Change this line of code (notice the underlined).
    Please Login or Register  to view this content.
    As far as I know, you can add as many replaces as you please.
    Hope this helps. John

  8. #8
    Registered User
    Join Date
    08-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Find & Replace data with multiple If range

    Thanks jaslake

    Rgds,
    Miners

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find & Replace data with multiple If range

    Glad I could help. If your satisfied, please mark your post as solved.
    John

+ 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