+ Reply to Thread
Results 1 to 10 of 10

Vba logic to pull data from various workbooks based on date

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Vba logic to pull data from various workbooks based on date

    Hello,
    Need to write a complicated logic into vba:
    Here is the scenario, there are two textboxes in a userform where one would enter a start date and an end date. The code i have would pull dated data from a workbook based on both dates. This is a relatively simple task for the code to do if we are dealing with one workbook, however, being that we have multiple workbooks, (minimum 10 mega bites each!) where every workbook represents an entire year's worth of data, the logic to create the vba code seems a bit more complicated.
    The workbooks are named this way : DataBase2013, DataBase2014, DataBase2015, DataBase2016........

    What logic would anyone suggest that i use?

    I'm really looking forward to all responses

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Vba logic to pull data from various workbooks based on date

    How many workbooks do you have? Are the Sheets names the same for each workbook? Can you share the code you are already using for one workbook?

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Vba logic to pull data from various workbooks based on date

    Hi John,
    Thanks for your reply
    I currently have workbooks since 2013. I have this one main workbook that accesses information for only this year, trying to get it to access the previous years as well and years to come.
    All the sheets are named the same way: "Offers".

    So here the code (still in the works) for dealing with a single workbook:
    Please Login or Register  to view this content.
    Oh, and one more point!...if the user enters a start date of 1/6/2013 and an end date of 6/2/2016 how can a logic be written to have the code open all the workbook that are between those dates?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Vba logic to pull data from various workbooks based on date

    What about the sheet names? How is wsV defined? Is it the same in each workbook?

  5. #5
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Vba logic to pull data from various workbooks based on date

    Yes, wsv is defined as a sheet and is found in each workbook. The only difference between all the workbooks is the year at the end of the filename.

    Thanks.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Vba logic to pull data from various workbooks based on date

    With all the workbooks open, maybe:

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Vba logic to pull data from various workbooks based on date

    Dear John,
    THANKS!!!!
    Your suggestion left me open-mouthed! It works great and i never would have thought of that!
    I also appreciate very much that you went out of your way to write the code down for me

    I did a couple minor changes to get the code to work with my system:
    Please Login or Register  to view this content.
    The only issue i am having is that the code works with the latest workbook and then moves down, i would like for it to start with the earliest workbook and move its way up.
    is this possible?

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Vba logic to pull data from various workbooks based on date

    When you use the workbooks collection it will start with the first one opened? The first workbook you open will be Workbook(1), the next Workbook(2) ect. ect.

  9. #9
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Vba logic to pull data from various workbooks based on date

    Quote Originally Posted by JOHN H. DAVIS View Post
    When you use the workbooks collection it will start with the first one opened? The first workbook you open will be Workbook(1), the next Workbook(2) ect. ect.
    Wow! Awesome! It worked just as you said
    I am on such a high right now
    Thank you and all the best to you!

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Vba logic to pull data from various workbooks based on date

    You're welcome. Glad to help out and thanks for the feedback and the reps.

+ 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. Pull Data from row based on date in first cell
    By dgroff in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-08-2015, 01:48 AM
  2. Pull row of Data based on date
    By sjone24 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-19-2013, 10:34 AM
  3. Pull data from worksheet based upon date
    By pyrofenix in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2013, 12:55 PM
  4. Pull data based on date match
    By tommypkoch in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-07-2012, 11:13 AM
  5. Pull data based on date
    By culverhr in forum Excel General
    Replies: 2
    Last Post: 09-13-2011, 02:02 PM
  6. Excel 2007 : Formula to pull data based off date
    By sjone24 in forum Excel General
    Replies: 0
    Last Post: 12-15-2010, 06:13 PM
  7. Pull Data based on a date criteria
    By Nolesphan30 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-01-2008, 12:22 AM

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