+ Reply to Thread
Results 1 to 8 of 8

Filter Cells by Date & Paste to Another Sheet

  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Filter Cells by Date & Paste to Another Sheet

    I have 900 rows of data of which there is a cell in each row that designates the date the data was entered.
    I made another sheet where I'd like to run a macro that will go through each row and determine if the date the data was entered is >= the (current date - 1).
    This way I would have all data entered within the past 24 hours.

    I am not anywhere near a programmer, but this is what I thought of:

    for i = 1 to 900
    if "N " & i + 1 >= "todays date" - 1

  2. #2
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Filter Cells by Date & Paste to Another Sheet

    I have 900 rows of data of which there is a cell in each row that designates the date the data was entered.
    I made another sheet where I'd like to run a macro that will go through each row and determine if the date the data was entered is >= the (current date - 1).
    This way I would have all data entered within the past 24 hours.

    I am not anywhere near a programmer and most of my code is junk, but it should paint a picture of what I'm trying to accomplish (the date is in column N in each sheet):

    Please Login or Register  to view this content.
    Thanks in advance!

    Luke
    Last edited by Cutter; 09-20-2012 at 11:37 AM. Reason: Replaced ITALIC tags with CODE tags

  3. #3
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Filter Cells by Date & Paste to Another Sheet

    I just realized I made a mistake in the paste location.
    It would be in sheet "Daily Data" but in row i + 1, not in cell "N".

  4. #4
    Registered User
    Join Date
    08-27-2012
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filter Cells by Date & Paste to Another Sheet

    This is what I would do, more or less. If you post an example before/after file I can write it specifically.


    Please Login or Register  to view this content.
    Piggy

  5. #5
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Filter Cells by Date & Paste to Another Sheet

    Thanks for the post. Your code looks very close to what I'm trying to accomplish. I tried tweaking it myself to no avail. The changes I'm looking for:
    I'd like to run the macro once I open the file, so the code would select the sheet "All Data" then copy the rows that have the data entry of "date - 1" from column "N" and paste those rows into the next available row in a different sheet called "Daily Data".
    Thats all Ihave for now. Once I have the daily data, then I have to see how I want to sort it in order to graph. But this macro will do wonders for me since I'll be able to adjust it to copy data from the past week or past month as well.
    Thanks, again, in advance.

    Luke

  6. #6
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Trouble with copy/paste from if statement

    Someone else on this forum help me get this, but it wasnt perfect for my application. I've been trying to tweak it all morning, but for whatever reason, my if statement only copies the first row of data to the other sheet instead of all the rows which pass the condtion.

    In case you cant tell from the code, I'm comparing the dates in column N to the current date minus 1. If the date is greater than (within the past 24 hours) then it copies that whole row and pastes it into the same row on another sheet. FYI: my level of competency with macros is very elementary. Thanks in advance! - Luke

    Please Login or Register  to view this content.
    Last edited by Cutter; 09-22-2012 at 02:57 PM. Reason: Added code tags

  7. #7
    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: Trouble with copy/paste from if statement

    Please Login or Register  to view this content.
    Make sure that the correct sheet is active when the code runs.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Trouble with copy/paste from if statement

    Hello , and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following. Thanks.

    You have posted duplicate threads and, thereby, broke Rule 5 of our forum rules. The duplicate threads would normally be closed but on this occasion they have been merged. Please continue in the one thread until it reaches a conclusion.

+ 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