Adding city names by rows

lelis

New Member
Joined
May 16, 2017
Messages
4
CityRisk LevelRisk LevelsDesired City 1City 2City 3City 4City 5
AboboExtremely Low RiskExtremely Low Risk3 AboboEndertaRaya Azebo
GodereVery High RiskVery Low Risk4 DimmaAbergeleMekele Special ZoneHintalo Wajirat
DimmaVery Low RiskLow Risk4 AdwaMereb LeheSamreLare
Gambela Low RiskModerate Risk5 Gambela ZuriaDegua TembienAlajeNaeder AdetWanthou
Gambela ZuriaModerate RiskHighly Moderate Risk2 GogEnticho
GogHighly Moderate RiskHigh Risk2 EndamehoniJor
JorHigh Risk Very High Risk1 Godere
AkoboExtremely Low Risk
JikawoVery Low Risk
LareLow Risk
WanthouModerate Risk
EndertaExtremely Low Risk
OflaVery High Risk
Hintalo WajiratVery Low Risk
SamreLow Risk
AlajeModerate Risk
AlamataHighly Moderate Risk
EndamehoniHigh Risk
Raya AzeboExtremely Low Risk
AbergeleVery Low Risk
AdwaLow Risk
Degua TembienModerate Risk
EntichoHighly Moderate Risk
Kola TembienHigh Risk
La'ilay MaychewVery High Risk
Mek'eleExtremely Low Risk
Mekele Special ZoneVery Low Risk
Mereb LeheLow Risk
Naeder AdetModerate Risk

<colgroup><col width="106" style="width:80pt"> <col width="161" style="width:121pt"> <col width="46" style="width:35pt"> <col width="160" style="width:120pt"> <col width="64" style="width:48pt"> <col width="106" style="width:80pt"> <col width="124" style="width:93pt"> <col width="147" style="width:110pt"> <col width="142" style="width:107pt"> <col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>

Hi, I used this formula to get the desired cities randomly from the City column. However the cities desired increment by columns (horizontally) instead of by rows(Vertically). I want the cities to be added vertically. For ex:

Desired City 1

<tbody>
</tbody>
3 Adobo
Enderta
Raya Azebo

This is the formula I used: =IF(COLUMNS($F2:F2)>$E2,"",INDEX($A:$A,SMALL(IF($B$2:$B$30=$D2,IF(ISNA(MATCH($A$2:$A$30,$E2:E2,0)),ROW($B$2:$B$30),0),0),RANDBETWEEN(COUNTIF($B$2:$B$30,"<>"&$D2)+COLUMNS($F2:F2),ROWS($B$2:$B$30)))))

Please let me know if there is a way to do this.

Thank you very much in advance.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi,

I found some solution, but to understand it You should probably look into my sheet in Excel Online:
https://1drv.ms/x/s!AlDc4uNa3Ao8gypyQf0aeSpV7HwD

Here are the formulas used in the solution:


Excel 2016 (Windows) 64 bit
ABCDEFGHI
1CityRisk LevelRisk Levels
2AboboExtremely Low Risk0.142876Risk levelVery High RiskExtremely Low Risk
3GodereVery High Risk0.406627Desired5Very Low Risk
4DimmaVery Low Risk0.634598CitiesOflaLow Risk
5GambelaLow Risk0.590462GodereModerate Risk
6Gambela ZuriaModerate Risk0.929963La'ilay MaychewHighly Moderate Risk
7GogHighly Moderate Risk0.828701High Risk
8JorHigh Risk0.12128Very High Risk
9AkoboExtremely Low Risk0.612942
10JikawoVery Low Risk0.984366
11LareLow Risk0.632343
12WanthouModerate Risk0.662796
13EndertaExtremely Low Risk0.340894
14OflaVery High Risk0.896094
15Hintalo WajiratVery Low Risk0.793369
16SamreLow Risk0.4936
17AlajeModerate Risk0.794289
18AlamataHighly Moderate Risk0.876628
19EndamehoniHigh Risk0.921099
20Raya AzeboExtremely Low Risk0.996822
21AbergeleVery Low Risk0.02916
22AdwaLow Risk0.518003
23Degua TembienModerate Risk0.763648
24EntichoHighly Moderate Risk0.55265
25Kola TembienHigh Risk0.881788
26La'ilay MaychewVery High Risk0.107096
27Mek'eleExtremely Low Risk0.420331
28Mekele Special ZoneVery Low Risk0.372463
29Mereb LeheLow Risk0.075304
30Naeder AdetModerate Risk0.394132
Sheet3
Cell Formulas
RangeFormula
D2=RAND()
G4{=IFERROR(IF(ROWS($F$4:F4)>$G$3,"",INDEX($A$2:$A$30,MATCH(LARGE(($B$2:$B$30=$G$2)*($D$2:$D$30),ROWS($F$4:F4)),$D$2:$D$30,0))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.


I hope this solves the problem.
Have a nice day.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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