Data import with Filter

  • I am struggling with this code, can seem to get it right. Can anyone help?


    I have a spread sheet I use to cost track jobs by the PO #, Im trying to create a macro i can run at will to automate the data transfer.


    Macro has to open a source workbook, search all of the worksheets for each occurrence of the PO# Range(A2) in the activesheet, each time it finds the PO copy the data from Col B, Col A, and Col K, paste that data back to the active sheet starting in the first available row of Col A


    Edited 3 times, last by truckingalong: Added Code Tags ().

  • Hi,


    Could you clarify the structure of workbook Job Ticket Log.xlsm


    Are you dealing with one or several worksheets ?


    Where can be located your searchvalue ? In column A or anywhere in the sheet (or the sheets...) ?


    Thanks for your clarifications


    P.S. Do not forget images are dead objects rather useless ... and attaching a sample file makes a huge difference ...!!!

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Carim,


    Thanks for your reply, I will try to lay out our system for you.


    I created a job ticket to replace the paper tickets the company was previously using. The job ticket has macros to perform several automations, including

    saving particular fields into a Job Ticket Log. I use the log to verify tickets, have a historical record of jobs completed by the month and year, and to track hours worked by certain groups. Job ticket log has a sheet named Data where everything is stored after a job ticket is completed. Job ticket log creates a new sheet named with the current month and year on the first day of each month, I cut and paste all the data from sheet (data) to the correct months sheet after I have verified the tickets.


    Funding workbook is where I track PO's for a particular customer, I enter all PO's into a list sheet (PO list), from there I can go to sheet (Master), and select the PO number from a drop down list, it auto populates data from the list sheet. Use the new sheet button, and it saves the sheet and clears the master template. Now to the point of the code...


    I wrote the code so after I have a PO sheet opened (active sheet) , I can run the copy data macro to open job ticket log workbook, look through all of the the sheets for the PO number (cell A2) in active sheet, it will always be in column I. Each time it finds the PO number, loop should move values and formats to funding workbook in which ever sheet you have active. Macro needs to place data in next available row beginning with cell A6, add rows if necessary would be nice.

    I would appreciate any help your willing to provide..


    Thanks


    see samples attached

    1. Job ticket

    2. Job ticket Log

    3 Macro test ( Funding Workbook)

  • Hi again,


    Just read your message extremely well structured ...!!!


    And my initial reaction is to send you all my congratulations for all the work you have already accomplished ... :thumbup:


    As soon as I have a moment, I will dive into the specifics of your workbooks, and get back to you as soon as possible ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Hi,


    There are several questions to tackle :


    1. Regarding Job Ticket Numbers ... shouldn't they be Unique ? ( #204123 appears twice in Rows 191 and 192 ... )


    2. Your current CopyData macro, when searching for the Purchase Order Number is coded to use Column A ... but the Purchase Order Number is located in Column I ...


    3. By design, each Purchase Order Number can have one of several Job Ticket Numbers attached ...and your pre-formatted report does set a max limit to 7 potential links ... is that right ?


    Thanks for your clarifications

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Morning,


    1. Job numbers should definitely be unique, dispatcher saved the ticket twice. I audit log at the end of each month and make necessary corrections.


    2. I thought it was coded to look through the whole sheet starting in column A, and ending in column K, although now that you mention it would make more sense only to look in column I.


    3. I am not sure about the max 7 links,

  • Thanks for your additional explanations which do help clarifying your request :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Hi again,


    Below is your revised Copy Macro to be tested ...


    Hope this will help :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • My understanding is that you sheet Data is regrouping all your various monthly data ....


    If it is not the case, would highly recommend not to carry on creating an individual tab for each month

    BUT to keep track of ALL your Job Ticket Numbers stored in a one single worksheet Data ...


    Regarding the macro runtime error, my assumption is that a Test to validate the Filter does produce results must be added to ensure macro does not generate errors...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

    Edited once, last by Carim ().

  • You are welcome.


    Will add the error handling in your macro and test it out ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Hi again,


    Below is your revised macro, which is checking (and counting) the number of visible records after filter has been applied, in order to avoid potential errors, whenever a given Purchase Order is not found in your reference Database :

    Hope this will help :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Carim

    Changed the title of the thread from “Data import” to “Data import with Filter”.
  • Hi,


    Once you have tested the revised macro, feel free to share your comments

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • What is your feedback ... ??? :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Thanks for your feedback AND for the Like 8)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!