+ Reply to Thread
Results 1 to 11 of 11

Module to apply to all open worksheets

  1. #1
    Registered User
    Join Date
    04-27-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    47

    Module to apply to all open worksheets

    Hi,

    I have a module, which lists, by date, the number of instances of certain words as defined at the top of the column.
    Anyway, this works fine - it operates on all sheets of a certain name type:

    Please Login or Register  to view this content.
    Which is what I want, but I want it to also operate on other sheets outside of the workbook eg all open sheets which fit the name criteria regardless of workbook - or all sheets within a given directory which match the criteria

    currently its:

    Please Login or Register  to view this content.
    but I'm not sure what to change it to - thinking it must be relatively simple..?

    the module code is this:


    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    04-27-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Module to apply to all open worksheets

    Actually, I think what I need is the following:

    Some way to copy data from multiple sheets in multiple workbooks to one main sheet on another workbook...

    that way I could pull all the data from the other worksheets in the other workbooks into a master sheet in my current workbook and run the module as normal...

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Module to apply to all open worksheets

    Using this line:
    Please Login or Register  to view this content.
    you are specifically looping through the worksheets in the book containing the code. You need a loop within a loop - something like:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Module to apply to all open worksheets

    If you just wanted to do it on each of the open workbooks then you can do something like this:

    Please Login or Register  to view this content.
    If you want to do it for each workbook in a certain directly it becomes a little more complicated, (but not overly). You just need to decide which you want to do.
    Also if you go with the latter option would you want to open and check EVERY Workbook in the particular directory, or only those with names that match a particular criteria?
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  5. #5
    Registered User
    Join Date
    04-27-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Module to apply to all open worksheets

    Thanks for your responses

    Ideally I would have it working on all workbooks in a given directory - this is safer.

    but it should definitely work on ALL workbooks in that directory, as that will be exclusively for the "raw data" books with data sheets in them.

    There would however be a specific range within the sheets that I would wish to copy - not the sheet - so the range would be like

    A3:F250



    Another thing that would be useful is if it only copied rows with data in them - but I don't want to ask for too much!!

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Module to apply to all open worksheets

    Quote Originally Posted by nhojflies View Post
    Actually, I think what I need is the following:

    Some way to copy data from multiple sheets in multiple workbooks to one main sheet on another workbook...

    that way I could pull all the data from the other worksheets in the other workbooks into a master sheet in my current workbook and run the module as normal...
    That would certainly be my advice based on our prior conversations... I think what you're looking to do is inherently risky esp. given volume of data at play ... ie what happens if old quarterly files are either moved or not open at the time of the calculation being invoked in the master file ?
    Based on my understanding you run the risk of generating (seriously) inaccurate results... having one central repository should help lessen that risk... nothing is fool proof but better to reduce risk as much as possible (consider yourself lucky you're not dealing with a Sales department!)

  7. #7
    Registered User
    Join Date
    04-27-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Module to apply to all open worksheets

    Thanks DonkeyOte.

    Yeah, the reason I want to seperate what is currently one workbook into multiple books is the following:

    The workbook is updated several times every day, sometimes by a few different people per day. The workbook is already pretty big and is only going to grow. I don't want folk to have to open a massive workbook every day.

    By dividing the workbook into one master sheet with the reporting charts on it and multiple - "quarterly data books" - the frequently updated data books are smaller and more manageable.

    When someone wants to view the stats for the period covered by all the data sheets, (which is infrequently,) it takes a bit more effort eg running a macro inthe master book to draw all the relevant data in from all the books.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Module to apply to all open worksheets

    I think we're talking on slightly crossed wires... by one central repository I don't mean running one workbook at all times I simply mean you have one central storage location - be it a purpose built database (Access, MySQL, SQLSvr, Oracl etc...) or one central file into which all the other files write their data ... so each "entry" file has an identical piece of code to "push" it's latest data to the central location... your summary file then only ever "pulls" from one location (the central repository) ... this would make your analysis much simpler and permit you to store your data in a more coherent fashion (ie negating the need for my UDF altogether).

  9. #9
    Registered User
    Join Date
    04-27-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Module to apply to all open worksheets

    oo er

    that sounds scary.

    If that is to be a solution, it would have to be one built by a different department. And to be honest, that's not going to happen.

    All I really want now is the best solution for having this big amount of data in excel workbooks, and being able to draw statistics from it in the way I've described.

    It may not be the slickest, but with the resources available, this is the best I can hope for..

    So ultimately it seems to be a choice of

    1. Creating a macro which when run pulls a specific range of data from sheets with a certain name type within open workbooks / all workbooks within a given directory

    2. Modifying the existing macro (as detailed in the first post of this thread) so that it operates on all open workbooks / all workbooks within a given directory.

    I can't figure out how to do either, so any help here would be much appreciated.

  10. #10
    Registered User
    Join Date
    04-27-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Module to apply to all open worksheets

    Hello,

    Just wanted to raise this one up again to see if anybody who hadn't seen it first time would have any ideas about potential solutions.

    In a nutshell - I have a working module which creates a table in one sheet by referencing data in various other sheets. These are all currently in the same workbook, but I want to divide the worksheets into a number of different workbooks and have the table reference "all open workbooks" or "all the workbooks in a given directory"

    Is there a way to do this?

    (the existing module is at the start of this thread)

    Thanks

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Module to apply to all open worksheets

    I thought that question had been answered, but maybe not.

    Some of the code may need further mods depending on the worksheet structure of the workbooks.
    Please Login or Register  to view this content.
    I agree with DO that this is vulnerable to errors that would be hard to detect.
    Entia non sunt multiplicanda sine necessitate

+ 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