+ Reply to Thread
Results 1 to 14 of 14

VBA Help - Search, Match, Copy

  1. #1
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    VBA Help - Search, Match, Copy

    Hi,
    What I have is a data sheet. In column A are the vendor names, B is PO #, C is Item #, D is Order Qty, E is unit cost, F is extended cost Then, there are sheets named for each vendor. What I would like to accomplish is matching vendor name in column A to the sheet named for that vendor, then copy and paste info. PO # will be a constant for each vendor, but there will be multiple items, qtys, etc.
    Below is a snapshot of where the data goes on the destination sheet:

    Column B --> "C2"
    Column C --> A2 & fill down
    Column D --> B2 & fill down
    Column E --> U2 & fill down
    Column F --> V2 & fill down

    I found code for simple match and fill by row, but this one is a little special since the source and destination are not an exact format match. Any help is greatly appreciated.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    Re: VBA Help - Search, Match, Copy

    I hope I have attached the file correctly. First tab is the Summary, where all data is contained. The following tabs are generated using VBA and the final step is to add to that code to then populate the tabs with the order info. In the first tab, I have populated the fields as the result should look.
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 07-26-2018 at 04:38 PM. Reason: Details

  5. #5
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    Re: VBA Help - Search, Match, Copy

    Brilliant! Works like a charm! Thank you!

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    You're welcome!


    Please click on Thread Tools and mark as Solved

  7. #7
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    Re: VBA Help - Search, Match, Copy

    Sorry, I hate to bother... I 'assumed' I would be able to modify the code written for the TEST file to work on my working file... unfortunately, some of the functions you used are WAY too advanced for me and I just cannot follow it well enough to modify. It really comes down to the source and destination locations being in different locations on the working file.
    I have reformatted the TEST file to be an exact match of the working file (source and destination). I really appreciate your expertise here.
    Attached Files Attached Files

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    For the new sample:

    Please Login or Register  to view this content.
    And, thanks for the rep!
    Last edited by xladept; 07-27-2018 at 12:02 PM.

  9. #9
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    Re: VBA Help - Search, Match, Copy

    Hi,
    Thank you so much. The new sample code works... and I see now how the cell reference work. However, when I put this into the working file, I am getting a subscript out of range error on this line:
    Z = Split(J, "~"): Set wv = Sheets(Replace(Z(0), " ", "") & Z(1))
    The Bold section is where the issue is. I do have other sheets in the working file... one is a master report, one is a template sheet that is used to create the vendor order forms and the last one is a data source file for the item codes.
    I suspect those other sheets are a problem?

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    The other sheets shouldn't be a problem. The error has to do with the sheet name. Either the sheet isn't named "VendorA123" or the Vendor and sequence number are different on the summary sheet.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    Correction:

    Please Login or Register  to view this content.
    Last edited by xladept; 07-27-2018 at 04:08 PM.

  12. #12
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    Re: VBA Help - Search, Match, Copy

    Thanks! I know what's wrong now... the Vendor column on the working file is a formula =CONCATENATE($P2,$R2)... when I copy and paste as text, it works. So, I think I'll have to insert a hidden column and then add a function in the macro to copy and paste as text to "Q" as the first step... does that sound like to correct solution?

  13. #13
    Registered User
    Join Date
    07-23-2018
    Location
    FL
    MS-Off Ver
    Office 365 Professional
    Posts
    28

    Re: VBA Help - Search, Match, Copy

    Actually, forget all of that... I think my brain is done for today! It wasn't even what I thought... it was something really riduculously dumb... Thank you so much for your time and help with this! It is working perfectly now!

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Help - Search, Match, Copy

    Things often work out that way - glad it's OK now!

+ 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: 10-06-2017, 05:02 PM
  2. [SOLVED] Folder search and copy when it found the match
    By misteyoso in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2017, 08:40 AM
  3. Search and copy based on partial text match
    By PIQalap in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2014, 11:36 AM
  4. [SOLVED] Search for SKU, if match then copy description from 1 Workbook in another
    By tripey in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 05-28-2013, 11:54 AM
  5. vba search Exactly Match Cateria then Copy and paste to next workshee
    By gingank in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-21-2013, 09:07 AM
  6. Compare, match, search and copy function
    By Blichfeldt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2013, 09:14 AM
  7. Replies: 4
    Last Post: 05-03-2012, 12:33 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