Select items at random based on date range

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
HelloWorld,


I have this challenge here with me and I need some help.


I want to look compare the day and month of the date in cell A2 with the date ranges below. Then when I find a match , I use that match to select at random one item from one of the arrays.


So if the match is seen in range A of the dates, then we select at random one item from arr(1).
If in date range B then arr (2)


In that order.




These are sample of date ranges :
Code:
A = 1st May – 30th June 
B = 1st July – 31st August 
C = 1st September – 31st October 
D = 1st November – 31st December 
E = 1st January – 29th February


Note :
These dates will be hard coded and will vary.


Say 23rd may – 17th June is a good example of what dates I will be using .


Only the day and month is needed here, the year is not needed in this situation.


My dates are in the format “dd-mm-yy”


These are the examples for the array I want to use :
Code:
Arr (1) = (“mango”, “apple”, “pear”, “orange”, “lime”)
Arr (2) = (“Tilapia”, “whale”, “Tuna”, “salmon”)
Arr (3) = (“Red”, “white”, “black”, “ash”, “violet”, “blue”, “green”)
Arr (4) = (“kia”, “hundai”, “Nissan”, “Toyota”)
Arr (5) = (“Dell”, “Lenovo”, “HP”, “Toshiba”, “Accer”)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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