+ Reply to Thread
Results 1 to 11 of 11

Return Data From Last 7 Days

  1. #1
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Return Data From Last 7 Days

    Hi all,

    I am having a senior moment when trying to extract data from a table for the past 7 days.

    In a sheet called 'Data', Column A has multiple dates (DATETIME format). The following columns (B,C,D etc.) contain other information that relate to these dates.

    What I am trying to achieve is to extract all data from any rows from the 'Data' sheet into a sheet called 'Summary', but only showing data from the last 7 days.

    Any help would be appreciated.

    Many thanks in advance,

    TM.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return Data From Last 7 Days

    Try this...

    Data Range
    A
    B
    C
    1
    Header
    ------
    Last 7
    2
    10
    7
    3
    9
    6
    4
    8
    5
    5
    7
    4
    6
    6
    3
    7
    5
    2
    8
    4
    1
    9
    3
    10
    2
    11
    1


    This formula entered in C2 and copied down to C8:

    =IF(ROWS(C$2:C2)>7,"",INDEX(A:A,LOOKUP(2,1/(A$2:A$20<>""),ROW(A$2:A$20)+ROWS(C$2:C2)-7)))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Re: Return Data From Last 7 Days

    Thanks for the quick reply Tony.

    I have attached the sheet to try and help explain myself better.

    As you can see on the 'Data' sheet, I have a list of dates in column A.

    On the 'Summary' sheet, I want to do a lookup from the data tab to only show entries from dates 7 days less than NOW(). I then want to return all other columns for dates that match the criteria.

    As an example, there should only be 4 entries on the 'Summary' sheet, as only 4 rows from the 'Data' sheet are less than 7 days old (from today's date).

    I just cannot figure out how to create the correct formula for this so that it automatically updates whenever the data changes.

    I hope this makes a little more sense..

    TM.
    Attached Files Attached Files

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return Data From Last 7 Days

    Sorry, I won't download files that contain VBA. (I don't want anyone's code messing up my UI)

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Return Data From Last 7 Days

    Try this array formula with dynamic range

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Return Data From Last 7 Days

    Or maybe this
    Enter array formula in C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    then enter formula in A4 and copy formula across and then down. Format Col A as Date/Time
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please see attached file.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Re: Return Data From Last 7 Days

    AlKey, that is exactly what I wanted!

    How you came up with that, I have no idea. But thank you very much for your help with this.

    TM.

  8. #8
    Registered User
    Join Date
    10-03-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    5

    Re: Return Data From Last 7 Days

    +1

    Almost there...
    Last edited by rtroehrig; 10-04-2018 at 11:54 AM.

  9. #9
    Registered User
    Join Date
    10-03-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    5

    Re: Return Data From Last 7 Days

    Quote Originally Posted by AlKey View Post
    Or maybe this
    Enter array formula in C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    then enter formula in A4 and copy formula across and then down. Format Col A as Date/Time
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please see attached file.
    Sorry for the dead thread revival, but this is the only thing I've seen that actually solved my dilemma.

    I tried using this on a spreadsheet I have. It is working for the most part, except it's returning 10/3/2018-10/15/2018 rather than 9/26/2018-10/3/2018.

    Any idea why?

  10. #10
    Registered User
    Join Date
    10-03-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    5

    Re: Return Data From Last 7 Days

    Quote Originally Posted by AlKey View Post
    Or maybe this
    Enter array formula in C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    then enter formula in A4 and copy formula across and then down. Format Col A as Date/Time
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please see attached file.
    Ok so I figured out why the dates weren't pulling right. My dummy sheet had dates past today's date.


    Now I have it all working except for one problem. If there is any data in Column F on Sheet 1, I lose that row completely on Sheet 2.

  11. #11
    Registered User
    Join Date
    10-03-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    5

    Re: Return Data From Last 7 Days

    Never mind. All dumb questions. I figured it out.

+ 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. Replies: 8
    Last Post: 07-02-2014, 01:39 PM
  2. [SOLVED] Return the number of days in a month from a data set
    By pickslides in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-08-2014, 08:02 AM
  3. [SOLVED] Return days and times from a table
    By greg19 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-04-2013, 07:50 PM
  4. [SOLVED] Number of Days Between Dates but if no Date go to next and return # of Days
    By Bikeman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-14-2012, 12:02 PM
  5. [SOLVED] Loop through date data and return with days per each week of the data
    By jeptha in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2012, 09:18 AM
  6. Return only work days
    By mhart210 in forum Excel General
    Replies: 1
    Last Post: 08-18-2005, 12:05 PM
  7. function to return days
    By crapit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2005, 09:05 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