+ Reply to Thread
Results 1 to 10 of 10

Matching last 5 digits of a number to a range and copying adjacent cells.

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

    Matching last 5 digits of a number to a range and copying adjacent cells.

    With the generous help I've been using a macro which checks a range of cells column C, and if any exact matches are found in Column B, then the values in this cell and the adjacent cell (in Column A) are copied/filtered to a new place within the sheet.

    What I'd like to know if it is possible to modify this macro so that it matches the last 5 digits of of the values in Column C to those in Column B, and if it finds a match to copy the values in columns A + C to a new place within the worksheet.

    A B C
    6011292 36395 202-4582623-2072315
    61794126 25164 202-5450013-1225164
    6011506 68390 026-8638442-4494713
    6016213 48365 202-0387539-0048365

    Here is the current macro I'm using. If anyone here can help me out it would be greatly appreciated. Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    Hi try this
    Please Login or Register  to view this content.
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

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

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    Thanks for taking a look at it for me, I'm getting a repeating subscript out of range error for
    Please Login or Register  to view this content.
    Any ideas for the reason behind it?
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    with such sample try this:
    Please Login or Register  to view this content.

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

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    It works nicely thankyou, however through testing it think I might have been a bit misleading in my example.

    What I want to accomplish is to have a macro that will see if the last 5 digits of a number in Column C match any number in column B, then if there is a match it would copy the cells in Column A + C.

    In the example below; the last 5 digits of C4 match B3, in which case I would want to copy A3 and C4 to cells D1 & E1.




    A B C D E
    6011292 36395 202-4582623-2072315 (Data from A3 will go here) Data from C4 will go here)
    61794126 25164 202-5450013-1225164
    6011506 48365 026-8638442-4494713
    6016213 68390 202-0387539-0048365
    6016547 68114 Empty

    Thats if it is even possible, I'm a bit out of depth here so any guidance would really help me out.
    Last edited by BPSJACK; 07-20-2012 at 04:41 AM. Reason: Correction in table

  6. #6
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    Hi in your post above description in text is not equal description in sample (picture).
    In E1 You expect data from C4 (text) or B3 (picture).
    Please make this clear.

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

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    My apologies of making it unclear, have corrected it now.

  8. #8
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    Look at this then
    Please Login or Register  to view this content.

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

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    That is absoluetly brilliant, it does exactly what I want it to do. Thanks for your help and patience!

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Matching last 5 digits of a number to a range and copying adjacent cells.

    @ BPSJACK

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself.
    Thanks.

+ 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