+ Reply to Thread
Results 1 to 8 of 8

Converting Date Range to Date Series

  1. #1
    Registered User
    Join Date
    04-29-2017
    Location
    London
    MS-Off Ver
    2016 Professional
    Posts
    50

    Converting Date Range to Date Series

    Dear All

    With reference to the attached spreadsheet and screenshot below I have a situation where the user enters employee holidays as a start date and end date (black table called data_tbl). In addition the user specifies if the holiday starts and ends in the morning or afternoon to allow for a 1/2 day at the either end of the holiday period. The number of days taken is calculated using the Networkdays function, in combination with IF functions, to determine the number of days taken.

    Capture.JPG


    As further processing of the data is required by way of using pivot tables / charts I need to convert the data entered by the user in to a new table similar to the blue table depicted called list_tbl. The new table should indicate if a 1/2 or whole day was taken for each date and allowance made so the it will refresh when data is amended, added or removed from the data_tbl. I guess this is a job for vba. I would welcome any assistance as my knowledge of vba is limited.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Converting Date Range to Date Series

    You don't need VBA for that. Since you have Office 2016, you can use M query language in Get & Transform (PQ) to do the transformation.

    1. Load the table by using Get & Transform -> From Table/Range.
    2. In PQ Editor, add custom column (name it DateList), with following formula.
    Please Login or Register  to view this content.
    3. Expand the result to New Rows.
    4. Add another custom column (name it WeekDay), with following formula.
    Please Login or Register  to view this content.
    5. Filter out Sat & Sun.
    6. Add another custom column (Days Taken), with following formula.
    Please Login or Register  to view this content.
    7. Change data types and reorder/remove columns as needed.
    8. Load to data model for use in Pivot table, or if you wish, to worksheet.

    See attached sample. I loaded table to data model and added pivot table. You can see applied steps by going to "Queries & Connections" and double clicking on "data_tbl".
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    04-29-2017
    Location
    London
    MS-Off Ver
    2016 Professional
    Posts
    50

    Re: Converting Date Range to Date Series

    Thank you CK76. Sorry i should have mentioned the solution needs to work in 2010

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Converting Date Range to Date Series

    2010 can have PowerQuery add-in and is free. Since it doesn't use data model. PQ functions work in both versions. Just return the result to sheet instead of loading to model.

    But I get that it may not be an option to install add-in. I'm bit busy right now, but will look at coding later, if others hasn't helped you by then.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Converting Date Range to Date Series

    Try something like below... See attached sample as well. "Sheet2" must be present. (Or just change the location as needed).
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Converting Date Range to Date Series

    Simply
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-29-2017
    Location
    London
    MS-Off Ver
    2016 Professional
    Posts
    50

    Re: Converting Date Range to Date Series

    Thank you both very much, CK76 and jindon. Now i see the vba I can understand what it is doing but i would not have got there on my own in a million years. Will study and try to learn.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Converting Date Range to Date Series

    You are welcome and thanks for the rep.

    However, I had misread you problem... should be like this.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Formula for converting a date to quarter and leaving blank cell for no date values
    By jayc2111 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-10-2019, 12:57 AM
  2. Replies: 4
    Last Post: 03-21-2018, 09:25 AM
  3. [SOLVED] highlight a series of cells based on the number of days in a date range
    By b2lynch in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-09-2014, 10:48 PM
  4. [SOLVED] Converting the fiscal week number to the date range.
    By Nunzio in forum Excel General
    Replies: 5
    Last Post: 12-13-2012, 08:23 PM
  5. Looking up a series of values over a date range?
    By Kitsan in forum Excel General
    Replies: 6
    Last Post: 10-10-2012, 08:17 AM
  6. How to automate the date range when building Time-series charts in VBA
    By vbanewbie1233 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2012, 08:11 AM
  7. [SOLVED] Date updates from worksheet to chart & changes date to a date series! Help!!
    By Jayjg in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-22-2005, 11:06 AM

Tags for this Thread

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