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


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
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!
officetab bottom
Say something here...
symbols left.
You are guest
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.