![]() ![]() Week_days(x_ind) = DateSerial(pYear, 1, i) ' then below given instructions will be executed If Weekday(DateSerial(pYear, 1, i), vbMonday) < 6 Then ' calculating days in year by using below given fomrulaĭay_in_year = DateSerial(pYear + 1, 1, 1) - DateSerial(pYear, 1, 1) In the above code area, type the below given code: 'declaring boolean variable This will open an area to write module code. This will open the below given code area:Īfter that go to insert tab and click on “Module”. Step 1:Īfter that go to the “Developer” tab, under the “code” section select the “Visual Basic” code. This will display a random date on console.Įxample 3: Example to generate random weekday date in excel by using VBA code. For this case, let’s generate a “weekend” date. Select “Workday” if user wants to generate a weekday. Select the “Date” tab and set the date in from and to input drop-down menu. This will open the below given “Insert Random Data” dialog box. From the newly appeared drop-down menu simply choose “Insert Random Data”. Step 1:Ĭonsider below given sample worksheet with A2, active cell.Īfter that go to the “Kutools” tab and choose “Editing” option. This will display a random weekday, as depicted below:Įxample 2: Example to generate random weekend date in excel by using the kutool. Consider below given formula snapshot Step 3: SUM(): it is a method used to calculate sum. WEEKDAY() − this method will generate a date lies in the weekday. Simply, call the method, and pass the required parameters to generate a date. ExplanationĭATE() is a predefined excel method to generate the date without any need to define a method. To understand the guided step, firstly create an excel sheet with below given table data:Īfter that go to A2 cell. Example 1: Example to generate random weekday date in excel. Same method can be used to generate both weekday and weekend dates. Second method allow user to use kutool to generate the random dates, and last method allow user to use the VBA code to generate the date randomly. First method is based on using predefined formula, to generate random date. In this tutorial, the user will understand three possible methods to perform this task. This tutorial is designed to help learners to understand the technique to generate random weekday or weekend date in excel. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |