+ Reply to Thread
Results 1 to 9 of 9

If number in Column A matches number in column B - Copy B cell and adjacent cells ?

  1. #1
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    Hi,

    I'm trying to update a macro I'm currently using but I need to expand a little further. Below is what I am trying to achieve:

    Ref #1 Ref #1a Ref #2 Qty. REF#1a REF#2 Qty.
    TEST0000001 TEST0000007 123 1 TEST0000004 127 1
    TEST0000002 TEST0000009 123 1
    TEST0000003 TEST0000011 124 1
    TEST0000004 TEST0000019 127 2
    TEST0000005 TEST0000004 127 1

    Basically, if a number in Column A (REF#1) matches a number in Column B (Ref#1a) I'd the macro to copy REF#1a and the adjacent cells to the right and paste them in a new column.

    Does anyone know how I might go about this because I'm absolutely stuck :s

    Jack
    Last edited by BPSJACK; 07-16-2014 at 11:53 AM.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    Try:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    That code works perfectly for the example, thank you.
    Last edited by BPSJACK; 07-16-2014 at 04:30 AM.

  4. #4
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    However, is there a way to expand on it a little. Currently it will match all Ref#1 numbers against all Ref#1a numbers and copy the first one it finds. Is it possible for a macro to recognise whether there are multiple entires of ref1#a and copy them all over to the next coumns.

    I've updated my sample table to make it a bit more clear.

    Ref #1 Ref #1a Ref #2 Qty. REF#1a REF#2 Qty.
    TEST0000001 TEST0000007 123 1 TEST0000004 127 1
    TEST0000002 TEST0000009 123 1 TEST0000004 119 1
    TEST0000003 TEST0000011 124 1
    TEST0000004 TEST0000019 127 2
    TEST0000005 TEST0000004 127 1
    TEST0000005 TEST0000004 118 1

    Any help you kind folks can offer will be very much appreciated.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    Try:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    That's brilliant, thank you so much!

    The only thing I added to it was to turn off screen updating as my worksheet has many thousands of lines.

  7. #7
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    Hi,

    I'm having some problems again implementing this code in my workbook.

    It seems to be repeating the results in the output column. I've attached an example does anyone know where I might be going wrong?
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    Sort of fixed/bodged it myself.

    Seems that one of my #Ref1 numbers was formatted slightly differently. So I converted the column to text, padded it out with zeros and pasted the values over the top and that seemed to fix it.

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If number in Column A matches number in column B - Copy B cell and adjacent cells ?

    Glad you got it sorted.

+ 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. [SOLVED] Delete rows if column A matches number and meets condition in another column
    By stokiejames09 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-05-2014, 05:03 PM
  2. [SOLVED] count number of cells in Column C that have a lesser or equal value to the adjacent cell
    By Geoff Jones in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-18-2013, 11:01 AM
  3. Replies: 5
    Last Post: 02-24-2012, 06:04 PM
  4. Replies: 4
    Last Post: 10-21-2010, 11:05 AM
  5. Match column between two sheets and copy row format once column number matches
    By kapil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2010, 07:54 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