How to Randomly Look Up and Select from Reference Table?

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
625
Office Version
  1. 2019
Platform
  1. Windows
I am trying to generate random outputs into OUTPUT TABLE 1 and OUTPUT TABLE 2 of the ITEM column.

There will be options to select from drop downs in the OPTIONS TO SELECT table of TYPE, LEVEL and LOCATION.

Output Tables 1 and 2 then get automatically populated with these chosen options in their respective columns.

The ITEM column of these tables should then randomly select a row from the Reference Table where it finds a match for criteria of ‘Cat.’, ‘Type’, ‘Lev.’, and ‘Loc.’

Of course, more than one match maybe be found and so one option needs to be randomly selected. There are situations where no matches will be found and so that result needs to be left blank in the ITEMS column of each table. There will also be situations where only one option will be found and so, that option would be selected by default.

Rows that have an ‘n’ in the ‘Act.’ Column of the Reference Table should be ignored.

It would be greatly appreciated if someone can point me in the right direction to find a solution to this problem. Thanks in advance, Dan.

Options To Select
TypeSTR
Level2
LocationF


Output Table 1
Cat.TypeLev.Loc.Item
CRSTR2F12
CPDSTR2F2
PSUSTR2F30
PLUSTR2F21Only option available and so it chooses it


Output Table 2
Cat.TypeLev.Loc.Item
CRMOB2H16
CPDMOB2H6Only option available and so it chooses it
PSUMOB2H35
PLUMOB2H24Only option available as other option is NON active ('n' in 'Act.' Column), and so it chooses it


Reference TableLoc.
AreaCat.TypeLev.HFAct.Item
CPDCPDSTR2y1
CPDCPDSTR2yy2
CPDCPDFLX13
CPDCPDFLX2yn4
CPDCPDMOB1y5
CPDCPDMOB2yy6
CPDCPDSK2y7
CPDCPDSK2n8
CPDCPDSTR2y9
CRCRSTR1yy10
CRCRSTR2y11
CRCRSTR2yy12
CRCRFLX213
CRCRFLX1yy14
CRCRMOB2y15
CRCRMOB2y16
CRCRMOB1y17
CRCRSK2yy18
CRCRSK2yyn19
UBPLUSTR1y20
UBPLUSTR2yy21
UBPLUFLX222
UBPLUFLX1y23
UBPLUMOB2yy24
UBPLUMOB2yn25
UBPLUSK1y26
UBPLUSK2y27
UBPSUSTR1y28
UBPSUSTR2yy29
UBPSUSTR2y30
UBPSUFLX2yn31
UBPSUFLX2yy32
UBPSUMOB1y33
UBPSUMOB2yy34
UBPSUMOB2y35
UBPSUSK2y36
UBPSUSK2yyn37
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I have been advised to put up my post in the form of a Mini Sheet and so I am reposting the data in that form.

Book2.xlsx
ABCDEFGHIKLMNOPQRST
1
2Options To SelectOutput Table 1
3TypeSTRCat.TypeLev.Loc.Item
4Level2CRSTR2F12
5LocationFCPDSTR2F2
6PSUSTR2F30
7PLUSTR2F21Only option available and so it chooses it
8
9Output Table 2
10Cat.TypeLev.Loc.Item
11CRMOB2H16
12CPDMOB2H6Only option available and so it chooses it
13PSUMOB2H35
14PLUMOB2H24Only option available as other option is NON active ('n' in 'Act.' Column), and so it chooses it
15Reference TableLoc.
16AreaCat.TypeLev.HFAct.Item
17CPDCPDSTR2y1
18CPDCPDSTR2yy2
19CPDCPDFLX13
20CPDCPDFLX2yn4
21CPDCPDMOB1y5
22CPDCPDMOB2yy6
23CPDCPDSK2y7
24CPDCPDSK2n8
25CPDCPDSTR2y9
26CRCRSTR1yy10
27CRCRSTR2y11
28CRCRSTR2yy12
29CRCRFLX213
30CRCRFLX1yy14
31CRCRMOB2y15
32CRCRMOB2y16
33CRCRMOB1y17
34CRCRSK2yy18
35CRCRSK2yyn19
36UBPLUSTR1y20
37UBPLUSTR2yy21
38UBPLUFLX222
39UBPLUFLX1y23
40UBPLUMOB2yy24
41UBPLUMOB2yn25
42UBPLUSK1y26
43UBPLUSK2y27
44UBPSUSTR1y28
45UBPSUSTR2yy29
46UBPSUSTR2y30
47UBPSUFLX2yn31
48UBPSUFLX2yy32
49UBPSUMOB1y33
50UBPSUMOB2yy34
51UBPSUMOB2y35
52UBPSUSK2y36
53UBPSUSK2yyn37
Excel Post
Cell Formulas
RangeFormula
P4:P7P4=$M$3
Q11:Q14,Q4:Q7Q4=$M$4
R4:R7R4=$M$5
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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