+ Reply to Thread
Results 1 to 4 of 4

Categorise dates by time since created

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    3

    Categorise dates by time since created

    Hi All

    I have a spreadsheet (CSV file) that I download once a week that gives me a date an event was created, but what I need to do is categorise these dates by the length of times since they were created.

    i.e

    Column A1 to A267 lists the dates

    What I would like in column D1 to D267 is based on column A: less than 3 months,less than 6 months, between 6 & 12 months, between 12 & 24 months, between 24 & 36 months, between 36 & 48 months, between 48 & 60 months, more than 60 months.

    The wording can be altered to suit, what I am looking for is a formula to be able to categorise at least 5 different date periods.

    I have searched a number of different formulas and its seems a nested If statement would work, but what I am not sure of is the best approach, was thinking of creating another column to simply count days since date created and then based on this columns figure have another column with the above categories, but it would be cleaner if possible to have it all in one column based on dates downloaded in column A.

    Finally I would like to have a button on the page that would run this formula each time I copy in the data, from what I have read this would be a macro, I have done simple VBA in the past and have understanding of how macros functions work and coding of buttons to run macros, its just getting a formula into a macro to do this.

    Any advice / direction would be appreciated

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Categorise dates by time since created

    Nested IF()'s would indeed work for this, but if you have 5 (or more), it can start to become tedious and problematic to trouble-shoot.

    What I would suggest is to create a small table that contains your time frames (3 months, 6 months etc - but just use numbers...3, 6, 12 etc) and then next to each, the wording you want.

    then you can use a vlookup() based on the date difference to return the wording you want. This has teh advantage of being expandable and adjustable
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    09-20-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Categorise dates by time since created

    Never thought of it this way and only last Friday was I working with the Vlookup function for another piece of work.....Will give it a go, as I am copying the downloaded data across each week would there be any value in having this in a macro so that I do not overwrite the formulas each time I copy data in and instead press a command button to run the formulas each time.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,418

    Re: Categorise dates by time since created

    Assuming a month is 30 days, then you could use this formula in D1:

    ="Less than "&INDEX({3,6,12,24,36,48},MATCH(INT((TODAY()-A1)/30)+1,{0,3,6,12,24,36}))&" months"

    then copy down. If your new data is only over-writing column A, then the formulae will remain intact.

    Hope this helps.

    Pete

+ 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. Excel 2007 : How to categorise into hours.
    By kanigelpula in forum Excel General
    Replies: 0
    Last Post: 08-15-2011, 11:42 PM
  2. Replies: 2
    Last Post: 05-20-2010, 04:19 AM
  3. Replies: 3
    Last Post: 05-27-2009, 05:37 AM
  4. Categorise points in scatter charts
    By DanHegarty in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-07-2008, 09:35 AM
  5. IF Formula to categorise amounts
    By stevo365 in forum Excel General
    Replies: 3
    Last Post: 03-06-2008, 10:00 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