+ Reply to Thread
Results 1 to 4 of 4

Macro to find value from one cell and replace to another

  1. #1
    Registered User
    Join Date
    11-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Macro to find value from one cell and replace to another

    My first post, apologies if this has been answered elsewhere, if it has, I couldn't find it!

    Example1.xls

    In the attached example I need a macro that will look through the data from A2 to I13. Wherever it sees a number it needs to replace it with one of the names in B19 to B30. For example, where number 1 is found it is automatically replaced with the value in B19 (adam). If the values from B19 to 30 change then they need to change in the table. IE I get a list of 12 names per season and it will work out the batting order for 9 weeks.

    I've tried recording a find and replace, played around with substitute but no joy. I'm wanting something that will find a value in a cell and replace with a value from another cell, then it also needs to loop. I'm really new to writing macros so any help would be greatly appreciated. Thanks very much.

    Scott

  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: Macro to find value from one cell and replace to another

    No VBA needed. Just make a duplicate of your table off to the right. Copy the whole table and paste in K1. Now use a "lookup" formula for the names that go with the positional values from the first table.

    The first formula in K2 is: =VLOOKUP(A2, $A$19:$B$30, 2, 0)

    That is copied down and across the new table to display the names.
    _________________
    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
    Forum Contributor Legend Rubber's Avatar
    Join Date
    09-21-2012
    Location
    Tillsonburg, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    392

    Re: Macro to find value from one cell and replace to another

    Wow, good quick solve there...
    mine was getting alot more complicated than that

  4. #4
    Registered User
    Join Date
    11-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Macro to find value from one cell and replace to another

    Great thanks Jerry - much appreciated.

+ 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