+ Reply to Thread
Results 1 to 6 of 6

How to tweak formula to change calendar to include date range

  1. #1
    Registered User
    Join Date
    03-01-2023
    Location
    Melbourne
    MS-Off Ver
    365
    Posts
    22

    How to tweak formula to change calendar to include date range

    Hello,

    I've canibalised another sheet already created for a different user by Pete_UK, attempting to make it work for my own project.

    Can someone tell me how I might adapt the following code to be able to calculate for a date spread between two columns:

    =IFERROR(INDEX('Event Log'!$B:$B,MATCH(G3&"_"&$C4,'Event Log'!$D:$D,0)),"")

    If it's impossible to understand without context, attachment is attached.
    See Calendar (2) tab for the canibalised version.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    03-01-2023
    Location
    Melbourne
    MS-Off Ver
    365
    Posts
    22

    Re: How to tweak formula to change calendar to include date range

    I've updated the attachment, fixing a small error with the dates and adding another small piece of knowledge that will probably be helpful...
    Attached Files Attached Files

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,421

    Re: How to tweak formula to change calendar to include date range

    What I have done in other files where a date range is needed is to expand the activities table so that there is one record for each day in the date range, and this is then used as the source data for the calendar.

    I'll try and dig an example out for you a bit later on.

    Hope this helps.

    Pete

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,421

    Re: How to tweak formula to change calendar to include date range

    Okay, there is an example workbook in Post #29 of this thread:

    https://www.excelforum.com/excel-for...-workbook.html

    In the events_data sheet I have moved the main data entry table to the right, and used two other tables to automatically generate records for each day required. The green columns (A and B) just pick up the number of days for each date range and then generate a cumulative sum of those days. Note that A2 is empty and B2 contains zero - this is important for the other formulae. This also means that the formulae in A3 and B3 (and subsequent rows) are actually looking at row 2 of the main data table.

    The blue area is the part which actually expands the data to give one record for each day, generating a date and reference number that the calendar can make use of. You can also control what is displayed on the calendar (column G), and in this particular case the OP needed a Crew column which controls the conditional formatting on the calendar.

    The formulae in the calendar sheet are essentially the same as you already have, but are now looking specifically in the blue area of the Events sheet.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    03-01-2023
    Location
    Melbourne
    MS-Off Ver
    365
    Posts
    22

    Re: How to tweak formula to change calendar to include date range

    Thanks Pete!
    I'd like to try and use Power Query for as much of this as I can (seems like it's a good way to keep things 'smart' but I might be wrong?)

    I've created an auto table that lists out the dates, similar to your example. Now I'm not sure if I'm able to have Power Query create the IF/COUNT function, as you have it in the formula.

    Is it possible?

    See new tab in the attached for "Get Date Event List" - I'm hoping you can open the Power Query function to see the steps I created to make that list.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-01-2023
    Location
    Melbourne
    MS-Off Ver
    365
    Posts
    22

    Re: How to tweak formula to change calendar to include date range

    I've attempted to add a colum and adding the following formula, but I'm getting a 'Token Comma Expected" error, hovering over the 'v' in 'Event'

    =[Event Date List]&"_"&COUNTIF(B$2:[Event Date List],[Event Date List])

    Screen shot showing highlighted 'error' here:

    Attachment 820362

+ 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: 5
    Last Post: 02-07-2022, 09:14 AM
  2. Replies: 1
    Last Post: 10-26-2020, 08:43 PM
  3. Calendar template formula tweak
    By MPosey in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-28-2014, 08:01 PM
  4. VBA Code tweak to include formats
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 11:08 AM
  5. Replies: 1
    Last Post: 02-09-2012, 04:13 AM
  6. Automating a date calendar to include business days
    By Gti182 in forum Excel General
    Replies: 4
    Last Post: 11-04-2010, 07:42 AM
  7. formula to indicate date range on a calendar
    By bnwash in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-12-2008, 06:02 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