+ Reply to Thread
Results 1 to 7 of 7

increment date by one day

  1. #1
    Registered User
    Join Date
    07-17-2008
    Location
    California
    Posts
    11

    increment date by one day

    Hello,

    I'm trying to show a date in MM/DD format going across five cells that represent the days of the week. I want to calculate the correct date after entering a start date. For example:

    I would modify the formula in cell B6 using the DATEVALUE formula by typing in a specific start date, such as:=DATEVALUE("6/30/2008")

    I would then like cells E11:I11 to show:

    E11: Mon,6/30
    F11: Tues,7/1
    G11: Wed,7/2
    H11: Thurs,7/3
    I11: Fri,7/4

    I chose to use the DATEVALUE function because I read that it's easier to add dates when converted into their serial number equivalent. I would also like to do this without VBA, if possible. If I'm attempting this all wrong, feel free to point me to the right direction.

    Appreciate the help!

    Emil
    Last edited by VBA Noob; 07-17-2008 at 03:06 PM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    increment date by one day

    Perhaps something like this....
    With
    E10: (any date....eg 7/9/2008)

    This formula returns the Monday date of the week containing the date in E10
    Please Login or Register  to view this content.
    Next, to fill in the rest of the week:
    Please Login or Register  to view this content.
    Copy F11 across through I11

    Last, make sure E11:I11 are formatted the way you want:
    • Select E11:I11
    • From the Excel Main Menu: <format><cells><number tab>
    • Category: Custom
    • Type: ddd, mm/dd <-(you'll need to type that part in)
    • Click [OK]

    In the above example, the formulas will return:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    07-17-2008
    Location
    California
    Posts
    11

    Thumbs up

    wow...

    i'm just learning as i go and i spent a long time working on this and actually came up with a solution. i was pretty proud of myself, too, but your code just made it so simple! my code did the job but can be compared to using a table saw to cut a piece of steak - it does the job but why not just use a steak knife?

    anyways...thanks for your quick response. i have another problem with the same workbook that i'm trying to solve that i'll post shortly. please look for it because i'm sure you can help me! i know it will involve vba, and i have no clue where to start! (if you can suggest a way i can get more practice with writing in vba, i would really appreciate it!)

    thanks again!

  4. #4
    Registered User
    Join Date
    06-15-2007
    Posts
    25
    Quote Originally Posted by Ron Coderre
    Perhaps something like this....
    With
    E10: (any date....eg 7/9/2008)

    This formula returns the Monday date of the week containing the date in E10
    Please Login or Register  to view this content.
    Next, to fill in the rest of the week:
    Please Login or Register  to view this content.
    Copy F11 across through I11

    Last, make sure E11:I11 are formatted the way you want:
    • Select E11:I11
    • From the Excel Main Menu: <format><cells><number tab>
    • Category: Custom
    • Type: ddd, mm/dd <-(you'll need to type that part in)
    • Click [OK]

    In the above example, the formulas will return:
    Please Login or Register  to view this content.
    Is that something you can work with?

    Hi was just looking through this thread and was quite interested..can you please explain in plain english what the last bit means...(E10,2 ETC....... E10-WEEKDAY(E10,2)+1[/CODE]

    Thanks

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Explanation for: E11: =E10-WEEKDAY(E10,2)+1

    Please Login or Register  to view this content.
    So...If you subtract a date's weekday_num from the date,
    the result is the Sunday date prior to that date.

    Adding 1 to that value is the Monday date for the week containing the date in E10.

    Please Login or Register  to view this content.
    Note: You can designate which day you want the week to start on
    in the WEEKDAY function by setting the 2nd argument value.
    See Excel Help on that function for the details.

    I hope that helps.

  6. #6
    Registered User
    Join Date
    07-17-2008
    Location
    California
    Posts
    11

    Question

    Hi, Ron -

    I'm seeing this in other formulas that I'm coming across and am not sure why it's written this way. You used it above:
    F11: =+E11+1
    Why is there a + sign right after the = sign? Why not just write it
    F11: =E11+1
    When I plug it in, I'm not seeing a difference either way.

    Curious,

    Emil

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    =+Ref vs =Ref

    You're correct...in that instance, there's no difference.
    I don't routinely type the equal sign AND the leading plus sign (+).
    It's probably there because I typed the plus sign then selected
    cell E11 (and Excel put the equal sign in for me). Other times I may start
    with the equal sign before selecting cells.

    I hope that helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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