+ Reply to Thread
Results 1 to 7 of 7

excel replacement macro question

  1. #1
    Registered User
    Join Date
    09-06-2009
    Location
    Long Island
    MS-Off Ver
    Excel 2003
    Posts
    2

    excel replacement macro question

    Here is the psuedal code.

    For column D
    If D1 contains "Merch Theft", Replace D1 with "MT"
    If D2 contains "Merch Theft", Replace D2 with "MT"
    ...
    ...

    For instance, if D1 says "Merch Theft, Fraud, bla", I want it to be replaced by "MT".

    I can fill up another cell by letting it equal to
    =IF(ISERROR(FIND("Merch Theft", D2)), "", "MT"), but I cannot figure out a way to replace the original cells with "MT".

    Thanks in advance.
    Last edited by Tian; 09-07-2009 at 11:50 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: excel macro question

    1) Enter your formula in an empty column
    2) Highlight the whole column of new answers
    3) Ctrl-C to copy
    4) Click on the first cell at the top of the original column of data (D1?)
    5) Click on Edit > PasteSpecial > Values
    6) Delete the helper column as it is no longer needed.


    As this is a one-off, no VBA is really necessary.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: excel macro question

    Hi

    Another option, without formulas:

    Select column D, press Ctrl-H (or Edit->Replace) and use:

    Find what: *Merch Theft*

    Replace with: MT

    Press the button Replace All


    HTH

  4. #4
    Valued Forum Contributor
    Join Date
    02-09-2006
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2016
    Posts
    1,075

    Re: excel macro question

    A macro is another way to make this change.
    Trish in Oz
    -------------
    A problem well defined is a puzzle half solved


    If you attach a sample of your workbook it will be easier to find a solution. Remember to remove/replace sensitive data before uploading the file. Look here if you need help with attachments:
    http://www.excelforum.com/faq.php?fa...b3_attachments

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: excel macro question

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  6. #6
    Registered User
    Join Date
    09-06-2009
    Location
    Long Island
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: excel macro question

    Quote Originally Posted by lecxe View Post
    Hi

    Another option, without formulas:

    Select column D, press Ctrl-H (or Edit->Replace) and use:

    Find what: *Merch Theft*

    Replace with: MT

    Press the button Replace All


    HTH
    This will only replace "Merch Theft" part of the string into MT, i want the entire cell to be replaced with MT as long as Merch Theft is a part of the cell.

    If this is an one time thing, i can do what JBeaucaire said, but we do this on a daily basis and everything else are already in place in a macro. it's an extra step for everyone to do the copy and paste.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: excel replacement macro question

    Quote Originally Posted by lecxe
    Select column D, press Ctrl-H (or Edit->Replace) and use:

    Find what: *Merch Theft*

    Replace with: MT
    Quote Originally Posted by Tian
    This will only replace "Merch Theft" part of the string into MT, i want the entire cell to be replaced with MT
    I'm thinking you read it and didn't try it.
    Entia non sunt multiplicanda sine necessitate

+ 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