2017-05-24 91 views
0

我仍然試圖弄清楚這一點。我在Excel中的一張表中有這些數據。excel選擇和隨機

City   Risk Level 
Facility 1 Extremely Low Risk 
Facility 2 Very High Risk 
Facility 3 Very Low Risk 
Facility 4  Low Risk 
Facility 5 Moderate Risk 
Facility 6 Moderate Risk 
Facility 7  High Risk 
Facility 8  Extremely Low Risk 
Facility 9  Very Low Risk 
Facility 10  Low Risk 
Facility 11 Moderate Risk 
Facility 12 Extremely Low Risk 
Facility 13  Very High Risk 
Facility 14  Very Low Risk 
Facility 15  Low Risk 
Facility 16  Moderate Risk 
Facility 17  Highly Moderate Risk 
Facility 18  High Risk 
Facility 19  Extremely Low Risk 
Facility 20  Very Low Risk 
Facility 21  Low Risk 
Facility 22  Moderate Risk 
Facility 23  Highly Moderate Risk 
Facility 24  High Risk 
Facility 25  Very High Risk 
Facility 26  Extremely Low Risk 
Facility 27  Very Low Risk 
Facility 28   Low Risk 
Facility 29  Moderate Risk 

Risk Levels   Desired 
Extremely Low Risk  3 
Very Low Risk   4 
Low Risk    4 
Moderate Risk   5 
Highly Moderate Risk 2 
High Risk    2 
Very High Risk   1 

我想知道是否有一個公式,可以從每個風險級別選擇所需的設施數量。例如:3個「極低風險」的設施,4個「非常低風險」的設施,4個「低風險」設施,5個「中等風險」設施......等等隨機我希望設施的名稱以列顯示,而不是按行顯示。

請讓我知道我該如何做到這一點。

非常感謝你提前。

回答

1

你可以使用這個公式:

=IF(COLUMN(A:A)<=$E2,INDEX($A:$A,AGGREGATE(15,6,ROW($B$2:$B$30)/(($B$2:$B$30=$D2)*(COUNTIF($E$2:E2,$A$2:$A$30)=0)),RANDBETWEEN(1,COUNTIF($B$2:$B$30,$D2)-COLUMN(A:A)+1))),"") 

enter image description here

+0

HI斯科特,這個看上去很不錯,謝謝你的這個幫助。但是有沒有什麼方法可以增加行數而不是列數? 對於前: 風險極低的風險非常低 基金1基金7 設施5設施30 設施10設施20 設施23 等等... 請讓我知道如果有一種方法我可以做到這一點。提前感謝你。 Graciela –