+ Reply to Thread
Results 1 to 5 of 5

Need to copy values from a range when matching records located in columns a & b

  1. #1
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Thumbs up Need to copy values from a range when matching records located in columns a & b

    I have the following scenario where I want to copy values from one range to a matching row based on values in columns A & B, see image below (I show in column D the 1st 7 records from column AE where both material and sample number match.

    In row 10 starting at column AB I may have several unique material numbers, these material numbers could be many, I'm only showing 2 in the image.

    What we need to do is loop thru each material number in column B and get the adjacent sample number in column A. Then locate the correct column for material number in columns AB onwards then find the matching sample number from column A. Then copy the cell value from the 3rd column to the right (shown as column AE and AI in image) adjacent to the material & sample number in columns A & B.

    Capture-5.PNG

    Thanks
    Last edited by jprlimey; 04-04-2018 at 07:16 AM. Reason: Solved

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Need to copy values from a range when matching records located in columns a & b

    You could do it with a formula.

    Put this in D2 and copy down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Need to copy values from a range when matching records located in columns a & b

    If you prefer a VBA solution:

    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Need to copy values from a range when matching records located in columns a & b

    Thanks to both AlphaFrog & GC Excel, both solutions work very nicely, now I must choose which will be the most effective for my application.

    I wasn't quite so sure how an index match formula would work, I did take a stab at it but couldn't get it to work.

    For the VBA solution, I must find time to understand more about the capability of the "scripting.dictionary", this is the second time it has been used for recent posts I have made.

    Thanks again

  5. #5
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Need to copy values from a range when matching records located in columns a & b

    Thanks for the feedback.

    Good idea to learn about the scripting.dictionary. This is a very powerful feature.
    To get you started: http://www.snb-vba.eu/VBA_Dictionary_en.html

+ 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. Find matching records in 2 sheets & copy related field values from one to the other
    By jkilday4 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2016, 05:04 PM
  2. Matching values to a range and then copy other values
    By Alfie101 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-28-2016, 11:38 PM
  3. Code to search for matching values in two columns, take text from that row and copy
    By Excelsemi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2014, 12:12 PM
  4. MS query needs to extract records with matching values
    By knuckleheadmike in forum Excel General
    Replies: 0
    Last Post: 05-16-2014, 10:35 PM
  5. Replies: 4
    Last Post: 08-08-2012, 01:21 AM
  6. Replies: 3
    Last Post: 02-06-2011, 05:29 AM
  7. Matching records in diff columns
    By Newtonboy in forum Excel General
    Replies: 3
    Last Post: 07-16-2006, 02:20 PM

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