+ Reply to Thread
Results 1 to 4 of 4

Need a Macro to Compare a cell in one sheet to a range in another and copy a specified cel

  1. #1
    Registered User
    Join Date
    05-08-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Need a Macro to Compare a cell in one sheet to a range in another and copy a specified cel

    I need some help if anyone would be able to provide it - I have tried multiple things and nothing works like I need it to.

    I have a sheet named "test" on the sheet named "test" I have a row beginning in Column "D2" ending in "D23" - I need to compare the cell in "D2" to a range in sheet "test2" the range is "A2:A100" - if a match to cell "D2" in sheet "test" matches any cell on sheet "test2" range "A2:A100" I need to copy the corresponding cells in sheet "test2". For example is cell "A8" in "test2" matches cell "D2" in sheet "test" I need to copy cells "B8"&"C8" from sheet "test2" and copy them and past to sheet "test" cells "G2"&"H2".......I need this to repeat for all cells in row "D2:D23" in sheet "test"


    I hope that makes sense - if anyone can help I would greatly appreaciate it.


    Thanks to all of you in advance,

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: Need a Macro to Compare a cell in one sheet to a range in another and copy a specified

    The vlookup function if placed in cells in columns G and H will accomplish this for you.

    Starting with G2: =vlookup(A2, 'test2'!$A$2:$C$100,2,False)
    In H2: =vlookup(A2,'test'!$A$2:$C$100,3,False)

    and then copy them down.

    Look at this link for further understanding. http://www.techonthenet.com/excel/formulas/vlookup.php
    Last edited by alansidman; 05-16-2014 at 08:43 AM. Reason: $ added
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-08-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Need a Macro to Compare a cell in one sheet to a range in another and copy a specified

    alansidman


    Thnak you very much!!! I had given up on the Vlookup because I was appearently doing something wrong! Thank you sooo much what you said worked perfectly!!

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: Need a Macro to Compare a cell in one sheet to a range in another and copy a specified

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks for the feedback and Rep

+ 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. Replies: 1
    Last Post: 01-03-2014, 03:01 AM
  2. macro to copy changing range to next blank cell in another sheet
    By d2whales in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2013, 12:55 PM
  3. Replies: 16
    Last Post: 01-20-2013, 09:40 AM
  4. [SOLVED] Macro: Dynamic creation of sheet based on cell value then copy range to the new sheet
    By BeachRock in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-15-2012, 11:31 AM
  5. Replies: 5
    Last Post: 01-14-2012, 05:45 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