Skip to main content

How to generate random weekday or weekend date in Excel?

This tutorial is talking about generate only random weekdays or only random weekend dates in Excel, follow below steps to get more details.

Generate only random weekday in Excel

Generate only random weekday or only random weekend with Kutools for Excel good idea3


arrow blue right bubble Generate only random weekday in Excel

In Excel, there are two methods can help you randomize only weekdays in a date range as you need.

Method 1 generate random weekday with formula

Select a cell and type this formula =DATE(2014, 1, 1)+LARGE(IF(WEEKDAY(DATE(2014, 1, 1)+ROW($1:$365)-1, 2)<6, ROW($1:$365)-1, ""), RANDBETWEEN(1, SUM(--(WEEKDAY(DATE(2014, 1, 1)+ROW($1:$365)-1, 2)<6)))), then press Shift + Ctrl + Enter keys simultaneously, then drag the fill handle to a range you want to generate weekday. See screenshot:
doc-randomoze-weekday-weekend-1

Tip:

1. If you want to generate unique random weekdays, you can use this formula =DATE(2014, 1, 1)+(LARGE(IF(WEEKDAY((DATE(2014, 1, 1)+ROW($1:$365)-1)*((COUNTIF($A$1:A1, DATE(2014, 1, 1)+ROW($1:$365)-1))=0), 2)<6, ROW($1:$365)-1, ""), RANDBETWEEN(1, SUM(--(WEEKDAY((DATE(2014, 1, 1)+ROW($1:$365)-1)*((COUNTIF($A$1:A1, DATE(2014, 1, 1)+ROW($1:$365)-1))=0), 2)<6))))) and remember to press Shift + Ctrl + Enter.

2. In above formulas, 2014,1,1 is the start date of your needed date range, 365 is the number of days in your date range, you can change them as you need.

3. You cannot put the formula generating unique random weekdays in A1.

Method 2 generate random weekday within a year with VBA

If you want to randomize weekdays within a year and are familiar to VBA, you can do as below:

1. Press Alt + F11 keys to open Microsoft Visual Basic for Applications window.

2. Click Insert > Module, then paste below VBA code to the popping windows.

VBA: Randomize weekday within a year.

Dim RandomizedYet As Boolean
'Updateby20150108
Function RandomizeDates(pYear As Long)
	Dim i As Long
	Dim DaysInYear As Long
	Dim xIndex As Long
	Dim RndIndex As Long
	Dim Temp As Date
	Dim Weekdays() As Variant
	If Not RandomizedYet Then
		RandomizedYet = True
		Randomize
	End If
	DaysInYear = DateSerial(pYear + 1, 1, 1) - DateSerial(pYear, 1, 1)
	ReDim Weekdays(1 To DaysInYear)
	For i = 1 To DaysInYear
		If Weekday(DateSerial(pYear, 1, i), vbMonday) < 6 Then
			xIndex           = xIndex + 1
			Weekdays(xIndex) = DateSerial(pYear, 1, i)
		End If
	Next
	ReDim Preserve Weekdays(1 To xIndex)
	For i = xIndex To 1 Step - 1
		RndIndex = Int(i * Rnd + 1)
		Temp = Weekdays(RndIndex)
		Weekdays(RndIndex) = Weekdays(i)
		Weekdays(i) = Temp
	Next
	RandomizeDates = Application.WorksheetFunction.Transpose(Weekdays)
End Function

3. Save the code and close the window to go back your worksheet, and type this formula=RandomizeDates(2014) into a cell, then press Enter key and drag the fill handle to a range you need. See screenshot:
doc-randomoze-weekday-weekend-2


arrow blue right bubble Generate only random weekday or only random weekend with Kutools for Excel

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

1. Select a range you want to generate weekdays or weekend dates, then click Kutools > Insert Random Data. See screenshot:
doc-randomoze-weekday-weekend-4

2. In the Insert Random Data dialog, click Date tab, and then calendar button to select a start date and end date you want, then check Workday or Weekend option you need, if you want to generate unique date, you can check Unique option. See screenshot:
doc-randomoze-weekday-weekend-4

3. Click Ok to apply and close the dialog, then in the selection, the unique weekend dates are generated.
doc-randomoze-weekday-weekend-5

Tip: If you are allowed to insert duplicates data, just uncheck Unique Values in the dialog

With Insert Random data function, you also can randomize integer, time, string and custom list. Click here for more information.


Best Office Productivity Tools

Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

kte tab 201905


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations