Adding city names by rows

lelis

New Member
Joined
May 16, 2017
Messages
4
[TABLE="width: 1120"]
<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>[TR]
[TD="class: xl59, width: 106"] City[/TD]
[TD="class: xl59, width: 161"]Risk Level[/TD]
[TD="class: xl59, width: 46"][/TD]
[TD="class: xl59, width: 160"]Risk Levels[/TD]
[TD="class: xl59, width: 64"]Desired[/TD]
[TD="class: xl59, width: 106"] City 1[/TD]
[TD="class: xl59, width: 124"]City 2[/TD]
[TD="class: xl59, width: 147"]City 3[/TD]
[TD="class: xl59, width: 142"]City 4[/TD]
[TD="class: xl59, width: 64"]City 5[/TD]
[/TR]
[TR]
[TD]Abobo[/TD]
[TD]Extremely Low Risk[/TD]
[TD][/TD]
[TD]Extremely Low Risk[/TD]
[TD="align: right"]3[/TD]
[TD] Abobo[/TD]
[TD]Enderta[/TD]
[TD]Raya Azebo[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Godere[/TD]
[TD]Very High Risk[/TD]
[TD][/TD]
[TD]Very Low Risk[/TD]
[TD="align: right"]4[/TD]
[TD] Dimma[/TD]
[TD]Abergele[/TD]
[TD]Mekele Special Zone[/TD]
[TD]Hintalo Wajirat[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Dimma[/TD]
[TD]Very Low Risk[/TD]
[TD][/TD]
[TD]Low Risk[/TD]
[TD="align: right"]4[/TD]
[TD] Adwa[/TD]
[TD]Mereb Lehe[/TD]
[TD]Samre[/TD]
[TD]Lare[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Gambela [/TD]
[TD]Low Risk[/TD]
[TD][/TD]
[TD]Moderate Risk[/TD]
[TD="align: right"]5[/TD]
[TD] Gambela Zuria[/TD]
[TD]Degua Tembien[/TD]
[TD]Alaje[/TD]
[TD]Naeder Adet[/TD]
[TD]Wanthou[/TD]
[/TR]
[TR]
[TD]Gambela Zuria[/TD]
[TD]Moderate Risk[/TD]
[TD][/TD]
[TD]Highly Moderate Risk[/TD]
[TD="align: right"]2[/TD]
[TD] Gog[/TD]
[TD]Enticho[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Gog[/TD]
[TD]Highly Moderate Risk[/TD]
[TD][/TD]
[TD]High Risk[/TD]
[TD="align: right"]2[/TD]
[TD] Endamehoni[/TD]
[TD]Jor[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jor[/TD]
[TD]High Risk [/TD]
[TD][/TD]
[TD]Very High Risk[/TD]
[TD="align: right"]1[/TD]
[TD] Godere[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Akobo[/TD]
[TD]Extremely Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jikawo[/TD]
[TD]Very Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lare[/TD]
[TD]Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Wanthou[/TD]
[TD]Moderate Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Enderta[/TD]
[TD]Extremely Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Ofla[/TD]
[TD]Very High Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Hintalo Wajirat[/TD]
[TD]Very Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Samre[/TD]
[TD]Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Alaje[/TD]
[TD]Moderate Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Alamata[/TD]
[TD]Highly Moderate Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Endamehoni[/TD]
[TD]High Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Raya Azebo[/TD]
[TD]Extremely Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Abergele[/TD]
[TD]Very Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Adwa[/TD]
[TD]Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Degua Tembien[/TD]
[TD]Moderate Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Enticho[/TD]
[TD]Highly Moderate Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Kola Tembien[/TD]
[TD]High Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]La'ilay Maychew[/TD]
[TD]Very High Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Mek'ele[/TD]
[TD]Extremely Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Mekele Special Zone[/TD]
[TD]Very Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Mereb Lehe[/TD]
[TD]Low Risk[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Naeder Adet[/TD]
[TD]Moderate Risk
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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:

[TABLE="width: 1120"]
<tbody>[TR]
[TD="class: xl59, width: 106"]Desired City 1[/TD]
[TD="class: xl59, width: 161"][/TD]
[TD="class: xl59, width: 46"][/TD]
[TD="class: xl59, width: 160"][/TD]
[TD="class: xl59, width: 64"][/TD]
[/TR]
</tbody>[/TABLE]
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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

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