Excel Dynamic Formula to List all Cities in a State

yagu99

New Member
Joined
May 26, 2011
Messages
7
I have an excel spreadsheet that has 3 Columns: 1) City 2) State 3) Population all on sheet 1. On Sheet 2 cell B1 I want to be able to select the state and display all cities within that state & their population. I would like to have a formula that accomplishes this and it needs to be dynamic as items get added to the spreadsheet. I do not want to use a filter or advanced filter. I have a formula but it is pulling back a list of all cities regardless of the state they are in. I would also like to remove the #REF from showing up on Sheet 2.
Sheet 1 Below:
City
State
Population
Orlando
FL
100
Winter Park
FL
10
Winter Garden
FL
5
Melbourne
FL
3
Cocoa
FL
2
Cocoa Beach
FL
4
Birmingham
AL
7
Las Vegas
NV
8

<tbody>
</tbody>


SHEET 2 RESULTS BELOW:
State Name
FL
List of Cities
Population
Orlando
Winter Park
Winter Garden
Melbourne
Cocoa
Cocoa Beach
Birmingham
Las Vegas
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!

<tbody>
</tbody>


Formula:
Code:
 =INDEX(Sheet1!$A$2:$A$9,SMALL(IF(Sheet1!$B$2:$B$9=Cities!$B$1,ROW(Sheet1!A2:A2)-ROW(Sheet1!$A$2)+1),ROW($A$3:A3)))
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
maybe a few modifications to what you already have...

=IFERROR(INDEX(Sheet1!$A$2:$A$9,SMALL(IF(Sheet1!$B$2:$B$9=$B$1,ROW(Sheet1!$A$2:$A$9)-ROW(Sheet1!$A$2)+1),ROWS($A$3:A3))),"")
 
Upvote 0
Select Sheet2!A1:A100 and enter this array formula.

=INDEX(Sheet1!$A:A,SMALL(IF((Sheet1!$B$1:$B$100=Sheet2!$B$1),ROW(Sheet1!$B$1:$B$100),9999),ROW(1:100)),1)&""

(entered with Ctrl-Shift-Enter (Cmd+Return for Mac))

The range Sheet1!B1:B100 (and 1:100 and the result range) should be expanded until it is longer than your longest possible list.
 
Upvote 0
Thanks for your responses, both formulas provide the City names, however, it still doesn't provide the population data for each city.
 
Upvote 0
if you copy the formula but change the index column to C you should get the population


=IFERROR(INDEX(Sheet1!$C$2:$C$9,SMALL(IF(Sheet1!$B$2:$B$9=$B$1,ROW(Sheet1!$A$2:$A$9)-ROW(Sheet1!$A$2)+1),ROWS($A$3:B3))),"")
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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