+ Reply to Thread
Results 1 to 8 of 8

help for writing a code to sort time and date column

  1. #1
    Registered User
    Join Date
    11-12-2015
    Location
    israel
    MS-Off Ver
    2010
    Posts
    4

    help for writing a code to sort time and date column

    I need to know how many cells there are for every half an hour in this column in an excel file

    how do i write this code in vba?

    Tue Jun 16 2015, 23:54
    Tue Jun 16 2015, 23:51
    Tue Jun 16 2015, 23:47
    Tue Jun 16 2015, 23:44
    Tue Jun 16 2015, 23:43
    Tue Jun 16 2015, 23:36
    Tue Jun 16 2015, 23:32
    Tue Jun 16 2015, 23:30
    Tue Jun 16 2015, 23:29
    Tue Jun 16 2015, 23:29
    Tue Jun 16 2015, 23:25
    Tue Jun 16 2015, 23:25
    Tue Jun 16 2015, 23:18
    Tue Jun 16 2015, 23:15
    Tue Jun 16 2015, 23:14
    Tue Jun 16 2015, 23:07
    Tue Jun 16 2015, 23:06
    Tue Jun 16 2015, 23:05
    Tue Jun 16 2015, 23:05
    Tue Jun 16 2015, 23:02
    Tue Jun 16 2015, 22:51
    Tue Jun 16 2015, 22:51
    Tue Jun 16 2015, 22:43
    Tue Jun 16 2015, 22:33
    Tue Jun 16 2015, 22:31
    Tue Jun 16 2015, 22:31
    Tue Jun 16 2015, 22:29

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,456

    Re: help for writing a code to sort time and date column

    I suspect this is going to be exactly what you want, but it should give you an idea of what you can do. It uses Text to Columns to split the data, which probably isn't recognised as a date and time into separate columns with date and time. It then puts a formula into column D which counts rolling 30 minute periods.

    Please Login or Register  to view this content.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    11-12-2015
    Location
    israel
    MS-Off Ver
    2010
    Posts
    4

    Re: help for writing a code to sort time and date column

    thanks!

    but how can I condition it to a specific time period ? ( like between 10:00 to 10:30 )

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,456

    Re: help for writing a code to sort time and date column

    Question is, where are you going to put those time bands? I'm just putting a formula out in to column D, basically because I can. But I can put the formulae anywhere and refer to whatever cells.


    Regards, TMS

  5. #5
    Registered User
    Join Date
    11-12-2015
    Location
    israel
    MS-Off Ver
    2010
    Posts
    4

    Re: help for writing a code to sort time and date column

    I just need to count how many cells there are between every round half an hour.
    meaning - how many cells there are between 09:00 to 09:30 and then between 09:30 to 10:00 and so forth

    so I will need to use a different formula that puts conditions on the time, right?
    I just don't know how to write this formula..
    so eventually I'll get something like this

    09:30 1
    10:00 0
    10:30 3
    11:00 4
    11:30 0

    so that I'll have one column with time and one column with the number of cells in this time period

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,456

    Re: help for writing a code to sort time and date column

    Please Login or Register  to view this content.

    Regards, TMS

  7. #7
    Registered User
    Join Date
    11-12-2015
    Location
    israel
    MS-Off Ver
    2010
    Posts
    4

    Re: help for writing a code to sort time and date column

    thank you so much

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,456

    Re: help for writing a code to sort time and date column

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. vba code to sort row 5 by date
    By lbesley in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-10-2014, 11:56 PM
  2. [SOLVED] How to sort the data by item code first, then sort them by date?
    By Zecond in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-04-2013, 01:55 AM
  3. Excel 2007 : sort by time in date/time field
    By bhavv in forum Excel General
    Replies: 1
    Last Post: 05-04-2012, 12:14 AM
  4. Writing code to fill a column
    By dalewms2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-31-2011, 04:03 PM
  5. Sort column with Date, Time and Text
    By dudedude in forum Excel General
    Replies: 2
    Last Post: 07-12-2010, 08:07 AM
  6. sort date/time
    By srroduin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2006, 03:15 PM
  7. Writing update date and time in a cell on inputs
    By a94andwi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2006, 09:45 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