+ Reply to Thread
Results 1 to 13 of 13

Multiple dates in one cell automatically

  1. #1
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Multiple dates in one cell automatically

    Hi all,

    I want to fill a single cell with dates, spaced by 7 from the input date until the end of the month.
    For example: I enter 02/01 (any format is fine) and the cell should fill with 02/01 09/01 16/01 23/01 30/01

    Is this possible?

    Thanks in advance for any help

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multiple dates in one cell automatically

    Famous last words but that is quite simple

    Can you give me more information?

    Is this for a specific cell, row or column?

    Right Click on your sheet name at the bottom excel and select view code.

    Paste this code in the macro window and close it.

    type 2/3 into cell B4.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-04-2016 at 05:04 PM. Reason: Debugged.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Re: Multiple dates in one cell automatically

    Thanks for getting back to me so quickly.

    Basically I need a formula that I can put in any cell.

    So for example, I type the number of days in the month (31) and then the starting point 03/01 and then have an output of all dates within that month including the start date

    So the output in this example would be: 03/01, 10/01, 17/01, 24/01 << All in one cell.

    The reason for this is that my job involves reoccuring appointments spaced a week apart and from this cell I will then be counting the number of dates (4 in this case) and multiplying by 2 in a different cell, this will then boil down my working hours.

    I hope this makes sense, please feel free to ask more if you need to.

  4. #4
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Re: Multiple dates in one cell automatically

    I should also mention that I was given this, but I cant get it to work.

    Function DaysToEOM(dte As Date) As String
    Dim s As String, n As Integer
    n = Month(dte)
    Do Until Not n = Month(dte)
    s = s & Format(dte, "dd/mm") & " "
    dte = DateAdd("d", 7, dte)
    Loop
    DaysToEOM = Trim(s)
    End Function

  5. #5
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Multiple dates in one cell automatically

    assuming your start date is in cell A1, and the number of days in the month are in B1 then enter this formular whereever:


    =TEXT(A1,"mm/dd") & IF((A1+7)>EOMONTH(A1,0),"",", " & TEXT(A1+7,"mm/dd")) & IF((A1+14)>EOMONTH(A1,0),"",", " & TEXT(A1+14,"mm/dd")) & IF((A1+21)>EOMONTH(A1,0),"",", " & TEXT(A1+21,"mm/dd")) & IF((A1+28)>EOMONTH(A1,0),"",", " & TEXT(A1+28,"mm/dd"))

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multiple dates in one cell automatically

    This will work in any cell.


    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Re: Multiple dates in one cell automatically

    Thats fantastic!

    Follow up question being, how to I count the number of dates in that cell now?

  8. #8
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Re: Multiple dates in one cell automatically

    Could you tell me how to use that please Mehmetcik.

    I assume it is a function so I add it in the visual basic editor.

    Beyond that I am pretty useless.

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multiple dates in one cell automatically

    This is a sheet specific macro.

    So you paste it into the sheet macro sheet as described above.

    Right click on the sheet name and select view code. Paste the code into the new window and close it.
    Enter 2/3 in any cell.

    *************************************************************************************

    Please explain where you would want to count the number of dates in the cell?

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


    This formula gets rid of the spaces and commas.

    Whats left are dates formatted dd/mm so divide by 5 to find how many dates.

    *************************************************************************************
    Attached Files Attached Files
    Last edited by mehmetcik; 03-04-2016 at 05:26 PM.

  10. #10
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Multiple dates in one cell automatically

    Assuming dates are in D1

    =LEN(D1)-LEN(SUBSTITUTE(D1,"/",""))

  11. #11
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Re: Multiple dates in one cell automatically

    Thank you very much you have both helped a lot!

  12. #12
    Registered User
    Join Date
    03-04-2016
    Location
    Germany
    MS-Off Ver
    2011
    Posts
    10

    Re: Multiple dates in one cell automatically

    Out of interest Mehmetcik, is it possible to change that code in to a formula?
    So I can enter it in specific cells.

    No is fine, just wanted to know.

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multiple dates in one cell automatically

    It formula is a lot harder because you would need to imitate a loop but it is possible.

    Also you would need to use two cells.

    If you want to use specific cells then the macro can be modified quite simply.

    You could colour the cells a specific color or insert a comment, or list it in variable in the macro.
    The options are endless.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 03-05-2016 at 07:31 AM.

+ 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: 3
    Last Post: 01-26-2014, 05:06 PM
  2. Replies: 3
    Last Post: 02-09-2012, 06:57 PM
  3. Automatically copy multiple cell VALUES to the cell right below the active cell
    By Sarangsood in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2011, 01:36 AM
  4. Automatically update dates based on cell contents
    By Spreadsheet Surfer in forum Excel General
    Replies: 2
    Last Post: 01-12-2010, 05:39 PM
  5. changing cell dates automatically
    By jonfouk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-22-2008, 04:46 PM
  6. automatically format dates in a cell
    By Stephan Laska in forum Excel General
    Replies: 3
    Last Post: 07-17-2006, 04:30 PM
  7. Replies: 4
    Last Post: 01-11-2005, 09:06 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