+ Reply to Thread
Results 1 to 9 of 9

cycling through a raw data report and creating multiple new reports

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    stinkyfeet
    MS-Off Ver
    Excel 2007
    Posts
    10

    cycling through a raw data report and creating multiple new reports

    *VBA noob*
    *sample workbook attached*

    i receive a report every quarter that is similar to the "raw data" sheet, where the values in column A are departments and the values in column B are customers. there are 50+ departments and each department has a varying number of customers each quarter, some customers are in multiple departments.

    I would like to create a program that grabs data from "raw data" for each department, popluates the "report" sheet with that data, saves the "report" sheet as a PDF using the department name in the filename, clears the report after save and moves down to the next department in "raw data" to repeat the process.

    I am having trouble determining how best to accomplish this goal; i can imagine calling multiple subroutines would perform this cleanly but I'm not comfortable with my ability to create them.

    the idea I have is to begin the PROCESS
    at "a3" in "Raw Data", do nothing until <>" ", name the notblank cell "department" and establish a range based on "department" to encapsulate the associated data: Range(.Offset(0, 1), .Offset(0, 4).End(xlUp).Offset(1, 0)).Name = "departcustomers"
    next, the "report" sheet would populate itself using IndexMatch formulas {formulas a, b, c} in c5:e15, formula a in column C, b in column D and c in cloumn E.
    then, the "report" sheet would copy a1:a2 from "raw Data" into "report" c1:c2 and copy "department" from "raw data" into "report"c3.
    at this point, "report" should look like "populated report 2036" and "report" should be saved as a pdf to the desktop {macro a}.
    finally, I want to clear "report" c:e 'i'm not sure if this is necessary
    repeat the PROCESS until there are no more departments, starting from the row below "department"

    I think this captures the intent of what I would like ...


    I am unsure if the most effective route would be to set up a main sub that calls the other subs like:
    Please Login or Register  to view this content.

    Thanks in advance for the advice and assistance
    -rufus




    {formula a}
    =if(isna(index([range"departcustomers".column 2],match("raw data" $b5, [range"departcustomers".column 1],0))),0,index([range"departcustomers".column 2],match("raw data" $b5, [range"departcustomers".column 1],0))

    {formula b}
    =if(isna(index([range"departcustomers".column 3],match("raw data" $b5, [range"departcustomers".column 1],0))),0,index([range"departcustomers".column 3],match("raw data" $b5, [range"departcustomers".column 1],0))

    {formula c}
    =if(isna(index([range"departcustomers".column 4],match("raw data" $b5, [range"departcustomers".column 1],0))),0,index([range"departcustomers".column 4],match("raw data" $b5, [range"departcustomers".column 1],0))

    {macro a}
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Cutter; 08-07-2012 at 01:22 PM. Reason: Added code tags

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

    Re: cycling through a raw data report and creating multiple new reports

    @ rufuswilson

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: cycling through a raw data report and creating multiple new reports

    Hi rufuswilson
    I'm certain there are a half dozen or so lines of code that can do as you require...well you're getting the "Blue Light" special...many lines that appear to do as you require.
    You'll need to change this line of code to tell the procedure where to save the .pdf files (don't forget the trailing backslash (\)).
    Please Login or Register  to view this content.
    See attached. Run the code from the button in Report worksheet...let me know of issues.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Registered User
    Join Date
    08-06-2012
    Location
    stinkyfeet
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: cycling through a raw data report and creating multiple new reports

    Many thanksfor the rapid reply, John. I am hitting a Run-time error code 1004. document not saved. the document may be open or an error may have been encountered when saving.; the debug button highlights the following at the end of the Create_Report sub:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: cycling through a raw data report and creating multiple new reports

    Hi rufuswilson

    What does this line of code look like in your file?
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-06-2012
    Location
    stinkyfeet
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: cycling through a raw data report and creating multiple new reports

    this is what I had changed it to:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: cycling through a raw data report and creating multiple new reports

    Hi rufuswilson

    Is there a folder on your desktop called myPDFs?

  8. #8
    Registered User
    Join Date
    08-06-2012
    Location
    stinkyfeet
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: cycling through a raw data report and creating multiple new reports

    John, there is now; and it works!! Thank you so much for your troubleshooting and the helpful code.
    rufus

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: cycling through a raw data report and creating multiple new reports

    You're welcome...glad I could help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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