Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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


Insert Random Data (insert random integer, date, time, string or custom list in a range.)

excel addin tool for generate random integers dates times strings custom lits

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

Kutools for Excel, with more than 120 handy Excel functions, enhance working efficiency and save working time.

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:

Kutools for Excel, with more than 120 handy Excel functions, enhance your working efficiency and save your working time.

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 120 handy Excel functions, enhance your working efficiency and save your working time.

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 randomize decimal integer 10

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.

pay attention1If you are interested in this addi-in, click here to download the 60-days free trial.


Select Range Randomly(Sort Range Randomly can quickly select or sort data randomly in a range/column/row.)

doc select randomly



Recommended Productivity Tools for Excel

Kutools for Excel Helps You Always Finish Work Ahead of Time, and Stand Out From Crowd

  • More than 300 powerful advanced features, designed for 1500 work scenarios, increasing productivity by 70%, give you more time to take care of family and enjoy life.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Brings Tabbed Browsing and Editing to Microsoft Office, Far More Powerful Than The Browser's Tabs

  • Office Tab is designed for Word, Excel, PowerPoint and Other Office Applications: 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!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.