+ Reply to Thread
Results 1 to 6 of 6

VBA for find and replace based on cell value

  1. #1
    Registered User
    Join Date
    07-13-2009
    Location
    QC, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    9

    VBA for find and replace based on cell value

    Hi I don't have that much experience with VBA programming and I usually just use recorded macros. Unfortunately I don't know how to solve this problem of mine. Can you guys help me out?

    Let's say I have a table with the ff data

    A B C
    1 2 2
    2 2 2
    1 2 2
    2 2 2

    Now on D1 I type the number 1 and on D2 I type the number 2. What I want the VBA to do is to search column A for all values that was placed on D1 (in this case the number 1) and replace them with what is placed on D2 (in this case the number 2). I don't want to touch the values on column B&C just the one on column A. Can this be done?

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA for find and replace based on cell value

    Hello kim_mandy36,
    1. Copy the code below to the clipboard using Ctrl+C.
    2. Right click the worksheet tab where the data is.
    3. Select View Code from the context menu.
    4. Paste the code using Ctrl+V.
    5. Save the changes using Ctrl+S
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-13-2009
    Location
    QC, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA for find and replace based on cell value

    I tried this but it wouldn't run. Does it take in to account the value to be searched in cell D1? What I plan to do with this macro is assign it to a button. I enter the data I want searched on the first column in D1, enter the data I want to replace it with in D2, then click the button to run the macro which will search for the D1 value in column one and replace them with the D2 value

  4. #4
    Registered User
    Join Date
    07-13-2009
    Location
    QC, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA for find and replace based on cell value

    Sorry I don't know if I can do this but I need to bump this up again

  5. #5
    Registered User
    Join Date
    07-13-2009
    Location
    QC, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA for find and replace based on cell value

    Can I bump this up again?

  6. #6
    Registered User
    Join Date
    07-13-2009
    Location
    QC, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA for find and replace based on cell value

    I finally found the answer on this site (credit goes to Tom Ogilvy)

    http://en.allexperts.com/q/Excel-105...lace-VBA-1.htm
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 06-05-2012 at 12:55 PM. Reason: Added Code Tags

+ 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