+ Reply to Thread
Results 1 to 7 of 7

Array to Find Workbook, Print Sheets from a List

  1. #1
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Array to Find Workbook, Print Sheets from a List

    I am posting this pseudo code in the hopes that someone may be able to actually flesh it out.
    I had tried doing this myself but I'm having a hard time trying to set objects and work out the array.

    In essence, I have a main file that contains a list of Workbook Names, their respective sheet names and the number of printed copies needed.
    I wish to loop through the list,
    save all the values to an array,
    then open the directory folder,
    Find the first workbook,
    and print the sheets the required number of times.
    Close that workbook and go through the rest of the array.


    NOTE: The workbooks are not numbered as in the list example. They are all different names. Also this is for Excel 2007.

    I've included the test workbook.
    I haven't include the seven dummy workbooks that are listed.
    If you'd like, I can upload them anytime.

    Thanks in advance.

    Please Login or Register  to view this content.

    Mark
    Attached Files Attached Files
    Last edited by max57; 05-16-2010 at 09:24 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Array to Find Workbook, Print Sheets from a List

    This is how I would do that:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Array to Find Workbook, Print Sheets from a List

    Thanks JB.

    Your code is much more organized than what I originally had come up with.
    With one modification, it works just as hoped for.
    Please Login or Register  to view this content.


    There is a slight bug with the Loop.
    If there is a " " value in the Print Quantity column,
    the loop skips over the entire next file name.
    Please Login or Register  to view this content.



    Got any suggestions on how to remedy this?

    I've included the modified file.

    Thanks

    Mark
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Array to Find Workbook, Print Sheets from a List

    I took the path variable out of the macro itself and placed it above, perhaps you didn't see that? I don't like burying constants inside a macro, it makes it less than obvious that it's a variable all macros can use. Putting them at the top makes it more clear, a personal preference. Make that string value whatever you need to make it work, I test on C:\2010\.

    Yes, I put an END IF in the wrong place and it messed up the logic. Sorry about that. Here you go.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Array to Find Workbook, Print Sheets from a List

    JB,

    Thanks for pointing out that line. I had completely overlooked it.
    Please Login or Register  to view this content.

    In order to find that problem, I had stepped through the code and found it jumped out at the same location.
    Please Login or Register  to view this content.
    Although, I hadn't figured out exactly how to correct it.


    Many thanks for your time.
    This will save me lots of time.

    I have a quick question regarding:
    Please Login or Register  to view this content.
    in the actual work file, there will be summation formulas that will give me the Print Quantity. Should I change this to xlCellTypeFormulas?

    Thanks.
    Last edited by max57; 05-16-2010 at 09:23 AM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Array to Find Workbook, Print Sheets from a List

    Quote Originally Posted by max57 View Post
    in the actual work file, there will be summation formulas that will give me the Print Quantity. Should I change this to xlCellTypeFormulas?
    No, notice the range is column B only? We are making a range array of the workbook names, those are constants, yes?. The sheet names and quantities are being evaluated as an OFFSET from the workbook name.

    ==========
    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Array to Find Workbook, Print Sheets from a List

    Of Course!

    What was I thinking?

    Thanks again JB.

+ 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