+ Reply to Thread
Results 1 to 19 of 19

Change day of a date after every 24 lines

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Change day of a date after every 24 lines

    Hi All,

    In column A i want to fill it with date (dd-mm-yyyy) but I only want the days to tick over to the next day after every 24 cells down as that's when it hits the next day 12:00 AM. Reason is in column B I have a bunch of data that is sorted by hours starting from 12:00 AM through to 11:00 PM and then loops. I want to use column A to associate a date for every block of time from 12:00 AM through to 11:00 PM. Spreadsheet attached.

    Not sure where to begin but I would imagine I would have to manually enter a date column A in order for the formula to know which date to start from.

    I would be grateful for a solution to this.

    Sample file here: date-to-hours.xlsx

    Thanks!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,388

    Re: Change day of a date after every 24 lines

    Hi,

    Here is the easy way. Select the cells from A2 to A25. A2 will have the date and all the others will be blank. Double click the right lower corner of the selected range and it will auto fill what you want.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Hi Marvin,

    Thank you for the reply. That did help but I also need to fill the gaps with the dates. For example from A2 to A25 they should all be 1/12/2014 and then from A26 to A49 it should be 2/12/2014 and so on.

    Also, I just noticed the hours in column B are text "12:00 AM GMT+11:00" - how can I convert this to an actual time "12:00 AM" ? I don't mind if the solution requires me to insert another column to convert it.

    thanks again and I await your response.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,805

    Re: Change day of a date after every 24 lines

    Try this:

    Please Login or Register  to view this content.
    This should do what you want providing you list 24 hours of events. Your current worksheet does not do this.
    Last edited by alansidman; 01-15-2015 at 12:40 AM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2505
    Posts
    13,765

    Re: Change day of a date after every 24 lines

    You also have a "gap" in the timeline. At row 109 the time jumps from 10 am to 12 pm.

  6. #6
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    you're right, in fact there seems to be a few gaps. Okay the data doesn't seem to be consistent I might have to leave out the date.

    Can I get help on converting just the time in text to a real time ?

    The text time is formatted like this "12:00 AM GMT+11:00" but i just need "12:00 AM"

    Thanks Guys!

  7. #7
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Thanks! but it seems there was some inconsistency in the data and some hours were missing. I might have to leave out the date.

    Can I get help on converting just the time in text to a real time ?

    The text time is formatted like this "12:00 AM GMT+11:00" but i just need "12:00 AM"

    Thanks Guys!

  8. #8
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Quote Originally Posted by alansidman View Post
    Try this:

    Please Login or Register  to view this content.
    This should do what you want providing you list 24 hours of events. Your current worksheet does not do this.
    Thanks! but it seems there was some inconsistency in the data and some hours were missing. I might have to leave out the date.

    Can I get help on converting just the time in text to a real time ?

    The text time is formatted like this "12:00 AM GMT+11:00" but i just need "12:00 AM"

    Thanks Guys!

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,388

    Re: Change day of a date after every 24 lines

    Hi,

    Put this formula in A3 and copy it down.

    =IF(AND(MID(B2,7,2)="PM",MID(B3,7,2)="AM"),A2+1,A2)

    I'd then copy the whole column A and Paste it over itself using Values Only.

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2505
    Posts
    13,765

    Re: Change day of a date after every 24 lines

    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The double unary "--" coerces the text "time" into its underlying numeric value. Then format for time.
    Last edited by FlameRetired; 01-15-2015 at 12:55 AM.

  11. #11
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Change day of a date after every 24 lines

    A3=if(left(b3,8)="12:00 am",a2+1,a2)
    try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  12. #12
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    FlameRetired's solution seemed to work best - thanks all!

  13. #13
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,805

    Re: Change day of a date after every 24 lines

    Try this:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Quote Originally Posted by MarvinP View Post
    Hi,

    Put this formula in A3 and copy it down.

    =IF(AND(MID(B2,7,2)="PM",MID(B3,7,2)="AM"),A2+1,A2)

    I'd then copy the whole column A and Paste it over itself using Values Only.
    this worked up until line 25 - it couldn't interpret 11:00 PM GMT+11:00

  15. #15
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Quote Originally Posted by FlameRetired View Post
    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The double unary "--" coerces the text "time" into its underlying numeric value. Then format for time.
    this worked perfectly for the text time conversion

  16. #16
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Quote Originally Posted by alansidman View Post
    Try this:

    Please Login or Register  to view this content.
    Wow, that was impressive. I am still reviewing this one but it seems to be a kick a$$ solution - all at a click of a button.

  17. #17
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Change day of a date after every 24 lines

    Quote Originally Posted by alansidman View Post
    Try this:

    Please Login or Register  to view this content.
    WOW, this was an impressive solution and worked perfectly. It auto replaced the text based times with real times at a click of a button. Very nice!

  18. #18
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Change day of a date after every 24 lines

    A3=if(left(b3,8)+0<left(b2,8)+0,a2+1,a2)
    try this and copy towards down

    i hope it will solve your problem

  19. #19
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2505
    Posts
    13,765

    Re: Change day of a date after every 24 lines

    Glad these helped, and thanks for the rep!

+ 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. [SOLVED] Can't change code from Columns to Lines
    By Darker0ne in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-03-2014, 12:13 PM
  2. Change format of many lines
    By radical in forum Excel General
    Replies: 11
    Last Post: 09-10-2009, 06:33 AM
  3. [SOLVED] How to change #lines in Immediate Window
    By joeu2004@hotmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2006, 12:25 AM
  4. locate and change hidden lines
    By Todd -marietta in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-03-2005, 08:55 PM
  5. Change ABC$DEF into two lines in same cell ABC <nl> DEF
    By George in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2005, 01:05 PM

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