+ Reply to Thread
Results 1 to 4 of 4

Randomly generate dates of the current month and excludes weekends

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Texas
    MS-Off Ver
    Excel 2016, 2019
    Posts
    53

    Randomly generate dates of the current month and excludes weekends

    I am trying to create a form that randomly generate dates of the current month and excludes weekends.

    I tried to us “=RANDBETWEEN(DATE(2016, 08, 01),(DATE(2016, 08, 31))” this resolves the date range but I have to change the formula each month and it does not exclude weekends.

    I created a list of dates using the autofill option, selecting weekdays to remove weekend from my list but I can’t use the field location to substitute in the date field (DATE(2016, 08, 01).

    This method does not work because it involves modify this every month.

    I tried using “=WORKDAY(C2, 20, F2:F14)” which will exclude weekends and holidays I choose but I can’t seem to make random. I know I am close but…


    I have tried to include an attachment but When I select the attachment icon all I get is a small box.Capture.JPG
    Last edited by jaycee66; 08-02-2016 at 08:16 PM. Reason: Trying to add attachment

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

    Re: Randomly generate dates of the current month and excludes weekends

    Hi Jaycee,

    You can do a Weekday() function and add a second parameter/argument. I chose 2 so Monday would come back as a 1. Then Saturday and Sunday would be day 6 and 7.
    The logic goes like this. Pick a random day in a month. Then do the Weekday( ,2) on it. If it is 1 to 5 then it is a weekday and don't change it. If it is Saturday (6) then subtract a random between 1 and 5 days. If it is a Sunday (7) then subtract a random between 2 and 6.

    I've created some helper columns in the attached and a double if statement to get those random "work" days. See if you can follow my formulas and make one of your own.

    Random Dates without weekends.xlsx
    Last edited by MarvinP; 08-02-2016 at 08:37 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    Texas
    MS-Off Ver
    Excel 2016, 2019
    Posts
    53

    Re: Randomly generate dates of the current month and excludes weekends

    Marvin,
    Thanks for the quick reply. I am checking this out and will get back with you

    R/

    Jaycee

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Randomly generate dates of the current month and excludes weekends

    Try

    =WORKDAY(RANDBETWEEN(WORKDAY(DATE(A2,B2,0),1),WORKDAY(DATE(A2,B2+1,1),-1))+1,-1,$E$2:$E$20)

    A2 = Year
    B2 = Month
    E2:E20 = list of holiday dates.

+ 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: 1
    Last Post: 04-29-2016, 01:28 PM
  2. [SOLVED] Count days elapse using if isblank statement that excludes weekends
    By jedaicore in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 08-31-2014, 09:05 PM
  3. [SOLVED] Generate Dates Excluding Weekends
    By chbrandt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2010, 10:45 PM
  4. Replies: 4
    Last Post: 04-28-2010, 04:25 PM
  5. calculate a 24 hour cycle time which excludes weekends and public holidays
    By rammergu in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-18-2009, 05:44 AM
  6. How to generate dates for a month?
    By Jim9980 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2006, 08:17 AM
  7. How to generate #'s that excludes certain numbers?
    By dojistar in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-15-2005, 02:55 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