Randomize dates

reellavkastning

New Member
Joined
May 23, 2011
Messages
10
I want to randomize days in the month based upon having 31 days in some months and some others having 27 and 30....


=IF(OR(I2=1;3;5;7;8;10;12);RANDBETWEEN(1;31);IF(I2=2;RANDBETWEEN(1;27);RANDBETWEEN(1;30)))
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
=IF(OR(I2=1;[COLOR=red][B]I2=[/B][/COLOR]3;[B][COLOR=red]I2=[/COLOR][/B]5;[B][COLOR=red]I2=[/COLOR][/B]7;[B][COLOR=red]I2=[/COLOR][/B]8;[COLOR=red][B]I2=[/B][/COLOR]10;[B][COLOR=red]I2=[/COLOR][/B]12);RANDBETWEEN(1;31);IF(I2=2;RANDBETWEEN(1;27);RANDBETWEEN(1;30)))

Do you only have 27 days in February where you are? :confused:
 
Upvote 0
Another way:

=DAY(RANDBETWEEN(I2 - DAY(I2) + 1, EOMONTH(I2, 0)))
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,551
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top