+ Reply to Thread
Results 1 to 9 of 9

Macro to copy Data where Date is > Today()

  1. #1
    Registered User
    Join Date
    12-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    8

    Macro to copy Data where Date is > Today()

    I recently just built a web based program, and before being able to create an account you have to enter your Date of Birth. The data is then stored in Excel...anyway long story short...I want to be able to copy all of the data that is in the Excel spreadsheet where the DOB > Today() to a new workbook. I have seen posts similar to this, I just can't find code that does exactly this. In my Excel spreadsheet the date is in column R, and I would need the data copied from cells A - R copied to a new workbook, where Date > Today(). Can someone help me with code that would complete this action?
    Last edited by MrSmith12; 12-06-2011 at 11:56 AM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macro to copy Data where Date is > Today()

    You want to copy the row of data or the sheet's worth of data? Perhaps a mock workbook with mock data (non-sensitive data) showing the before and results of your requirements would be best as it would remove any guessing from the volunteers of this site.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Registered User
    Join Date
    12-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    8

    Re: Macro to copy Data where Date is > Today()

    I only want to copy the row of data that where the Date > Today(). The rest of the data can stay in the source workbook. Attached is a workbook with the same formatting, just filled with test data.
    Attached Files Attached Files
    Last edited by MrSmith12; 12-04-2011 at 10:39 PM.

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macro to copy Data where Date is > Today()

    Perhaps this will get you close to what you want
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    8

    Re: Macro to copy Data where Date is > Today()

    Awesome, that is almost exactly what I need. Two small tweak requests. One....when the code is executed, starting in row IW to the end of the workbook it will add #N/A. Is there a way to remove that portion of the code? Also, I think it would work better (this is totally my mistake, I'm sorry) if the data would be copied to a tab within the same workbook, not a new workbook....

    I tried to tweak the code to copy to a worksheet within the same workbook, and I can't figure it out I tried the below code, and just commented out your code...
    Please Login or Register  to view this content.
    Last edited by MrSmith12; 12-05-2011 at 09:53 AM.

  6. #6
    Registered User
    Join Date
    12-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    8

    Re: Macro to copy Data where Date is > Today()

    I am getting an error object required:
    Please Login or Register  to view this content.
    The line of code that it doesn't like is:
    Please Login or Register  to view this content.
    Last edited by MrSmith12; 12-05-2011 at 11:10 PM.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macro to copy Data where Date is > Today()

    You should try declaring a worksheet variable and using it for the worksheet "Testing". For example:
    Please Login or Register  to view this content.
    and then revise the loop using NWS, like:
    Please Login or Register  to view this content.
    and so on.

  8. #8
    Registered User
    Join Date
    12-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    8

    Re: Macro to copy Data where Date is > Today()

    Thanks for that tip, that worked perfectly! When I paste the data onto my new worksheet, how would I tell it to keep the source formatting? The header rows that it is copying are set to certain font's/font color, things like that, that I need to keep intact from worksheet to worksheet.

    I tried this code:
    Please Login or Register  to view this content.
    But it did not work.
    Last edited by MrSmith12; 12-06-2011 at 11:08 AM.

  9. #9
    Registered User
    Join Date
    12-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    8

    Re: Macro to copy Data where Date is > Today()

    Disregard my post from above, I set up a worksheet as a "template" that had all the right formatting I needed, then set the code to copy to that specific worksheet. Thank you tremendously for your help and assistance.

+ 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