+ Reply to Thread
Page 1 of 4 123 ... LastLast
Results 1 to 15 of 47

Thread: Macro To Pull Last week worth of Data out of a Worksheet

  1. #1
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Macro To Pull Last week worth of Data out of a Worksheet

    I have a sample work book with 2 worksheets, one is titled All Data", the other called "Last Week"

    Is it possible to write a macro, to pull data between a "given" time frame? I would like to build a macro to say, ok if this date is between this day and this day pull this data into a seperate worksheet, with this formatting. Any ideas of How I would approach this, or other suggestions?

    I was thinking maybe I could use a userform, to input the dates and to press submit, then have the macro create the sheet with the data that is called...but that is just a thought, not sure if that is possible or not.


    Update, Ok I have built a userform, but right now there is no codes inputted. Not sure how I connect the cells to the calendar option yet either...but I have attached the amended file...


    Ok I have built some code into it, but it still needs some work, check amended file, for updated information...
    Last edited by 00Able; 12-08-2010 at 08:51 PM. Reason: Updated Progress

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Check this out, done in XL'07
    Click J1 to reset the ComboBoxes, select the start date and the end date then click the button
    Attached Files Attached Files
    Last edited by davesexcel; 12-01-2010 at 09:17 PM.

  3. #3
    Forum Guru
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    5,359

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Hi

    I've attached a file that will hopefully get you going. Open your userform1, then select the from date textbox. This will open a calendar, so select your date then press the commandbutton. Same for the to date. Then press submit, followed by close.

    HTH

    rylo
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Quote Originally Posted by rylo View Post

    I've attached a file that will hopefully get you going.
    I have opened the file but...It states "Unable to find Object, Not available on this Machine", I can see inside the vb, but it will not let me see the calendar that you added, I am using a Mac, but running BootCamp with Windows 7 64bit, and Excel 2010...so I do not know what the problem would be... but I do appreciate you assistance
    Last edited by 00Able; 12-02-2010 at 05:04 PM.

  5. #5
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Quote Originally Posted by davesexcel View Post
    Check this out, done in XL'07
    Click J1 to reset the ComboBoxes, select the start date and the end date then click the button
    Dave, Once again you have came up with a solution to what I request, not sure quite how I will try to disect this to be able to use in my "real life" instances though.

    Because the Macro is "prebuilt" into an existing sheet, in this workbook, would I be able to go to a different workbook, and perform this same task? Let me restate that clearer... I have several huge files with lots of data recorded daily concerning differnent aspects of business each on seperate worksheets, some in different workbooks. But I want to compile one workbook, that has about 30 worksheets with different information but only showing the last week of data, so its not so HUGE... , without a bunch of copy paste copy paste, blah blah blah. As this is a task, that I have to complete every Monday. How can I use what you show to do this?

    Still not sure if that is clear enough for interpretation...so lets say I want to have a workbook with pages that mirror "Last Week" that you have done...but I dont want to go through all 30 worksheets and input the same date over and over again...as I want a composition for the same dates consistant in the entire workbook. Is it possible to have a "Front Page" and input the date, and have the worksheets reference the dates shown on that page.
    And...is it possible to pull the data from other workbooks that are on saved on my system, but are closed, into this "Weekly" workbook?

    If so any thoughts, on how to do this.


    I am open to anyones thoughts, concerns, ideas, suggetions, please feel free to comment.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    You may have to edit the msgbox, it is reversed.
    If you have additional queries to this thread. you will have to add additional information or examples, do you want to loop through worksheets and filterr them so the results are on one sheet?
    Last edited by davesexcel; 12-02-2010 at 12:56 AM.

  7. #7
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Ok, Here is a little example, that I set up...using a similiar format as Dave illustrated in the thread above.
    I am not sure how I can attach the calendar option to assist in Date Selection (it is already imported into the attachement in the VB program.)

    But if you look at the "Front Page" you will see what I want it to do. I want to be able to input a range of dates (again using the calendar option -all the code is in the vb already), and for it to automatically pull the data between those dates from the sheets labeled "Down Time Log (1st Shift)" and "Down Time Log (2nd Shift)" in an identical format and perfably sorted by Date/shift...so that I see both see Dec 1 first shift data, then Dec 1 second shift data, Dec 2 First Shift Data, Dec 2 Second Shift Data, in that order on the front page if the range is 12/1/ 2010 - 12/2/2010

    See attachment
    Also, I have installed a user form called, frmDateControl, as an alternative to the activex controls...
    Last edited by 00Able; 12-18-2010 at 11:17 AM.

  8. #8
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Hi 00Able

    In the attached, I've added a new UserForm2 (I didn't want to have to wade through your code that creates the Calendar so I added my own). There is code behind UserForm2 that you can review.

    I've also added Module1 that does all the grunt work for the Buttons on "FRONT PAGE"

    There is no error checking; should you decide to use this, you'll need to add that.

    Play with it and see if it does as you require.
    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 click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

  9. #9
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Unhappy Re: Macro To Pull Last week worth of Data out of a Worksheet

    Quote Originally Posted by jaslake View Post
    In the attached, I've added a new UserForm2 (I didn't want to have to wade through your code that creates the Calendar so I added my own). There is code behind UserForm2 that you can review.
    I can open the file but it will not let me use the calendar, I am having the same error that I did with rylos attachment earlier in this thread...

    I have opened the file but...It states "Unable to find Object, Not available on this Machine", I can see inside the vb, but it will not let me see the calendar that you added, I am using a Mac, but running BootCamp with Windows 7 64bit, and Excel 2010...so I do not know what the problem would be... but I do appreciate you assistance

    I don't know what else I can do to be able to view this, does anyone else have any ideas?

  10. #10
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Hi 00Able

    I'm running this on a Mac with Fusion but am using XP and Excel 2000 and/or 2007. I'll take another look at it using your calendar. It may take a while...lots of code there.

    John
    John

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

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

  11. #11
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    From my understanding of the calendar code, as I have used this in 3 seperate user forms is this:
    1. frmCalendar is just for the layout or appearance
    2. mGlobals show the dates as a string
    3. clsCmdButton makes all the buttons on the calendar works
    All 3 of those must go in a worksheet to make the calendar work (you do not need to modify those codes at all), the trick is to connect those three with the user form, and you do that by entering part of this code:
    Private Sub txtDate_Enter()
        g_bForm = True
        frmCalendar.Show_Cal
       ActiveControl.Value = Format(g_sDate, "Medium Date")
    End Sub
    Sounds easy for someone more skilled then me, but my issue is that I am not used to connecting it to a sheet without a userform, but I kind of like not having to use the userform, for this particular layout.

    I think I need to name the fields "Start Date" field and "Finish Date" field are in to show something like "txtStartDate" and "txtFinishDate" and then Link the above code to those fields.

    I have been playing around with it, and so far, no good.

    But I will keep trying and if I am successful, as always I will post my results, until then...any help is appreciated.

  12. #12
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Hi 00Able

    Take a look at this link http://social.answers.microsoft.com/...9-e757223ebdde it may help explain what's going on. Don't know if or how it helps but it may give you something to research in your spare time.

    John
    John

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

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

  13. #13
    Valued Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    242

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Quote Originally Posted by jaslake View Post
    Hi 00Able

    Take a look at this link http://social.answers.microsoft.com/...9-e757223ebdde it may help explain what's going on. Don't know if or how it helps but it may give you something to research in your spare time.

    John
    Very good read, wish I knew this before I installed Office 2010 in the 64 bit mode...Thanks for sharing.
    I checked out the downloads available for the 64 bit, but if you want to use it and share, you have to buy several licenses for it after the free trial period, as this is something I need my co-workers to use, and at work we use Office 2003 32 bit, I am not sure that this would be the best route for me to do. As I don't think the 64 bit will be compatible with the 32 bit version I use at work.

    So I guess I will keep plugging away at my previous thread...

  14. #14
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Hi 00Able

    Where did you get this calendar code? Perhaps if I looked at your source, I could understand how all this links together.

    John
    John

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

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

  15. #15
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Macro To Pull Last week worth of Data out of a Worksheet

    Hi 00Able

    Well, I got your code to run on my machine. I need to do a lot more testing but before I go beating the horse, I need to know if it runs on your machine.

    Again, error checking needs added.

    I'd still like to know the source of this code.

    Let me know what happens.

    John
    Attached Files Attached Files
    Last edited by jaslake; 12-05-2010 at 01:15 PM.
    John

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

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

+ 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.2.0