Extracting Officer Codes Based on City Selection in Excel

rasika_99

New Member
Joined
Mar 4, 2024
Messages
2
Office Version
  1. 2007
Platform
  1. Windows
I have a Excel sheet (Excel 2007) containing the names of cities and their corresponding officer codes. I need to extract the relevant officer codes when selecting a city from a dropdown menu in another sheet. Could anyone assist me with this? A screenshot is attached.
1725425592372.png

1725425640209.png
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi rasika_99,

This will do what you need, just add this formula in to cell D6 only. Formula will list all the matches from cell D5 downwards.

Also the formula will remove any duplicates.

PS change the 'Sheet5' to the name of your sheet and the refereces accordingly.

Excel Formula:
=UNIQUE(FILTER(Sheet5!$B:$B,Sheet5!$A:$A=$D$3))

My examples...
1725437893457.png
1725437930077.png
1725437955313.png


Also if you conditional formatting to column D, to add border if cell is not empty ( <>"" ) to keep the cell borders based on the selection.
 
Upvote 0
Hi rasika_99,

This will do what you need, just add this formula in to cell D6 only. Formula will list all the matches from cell D5 downwards.

Also the formula will remove any duplicates.

PS change the 'Sheet5' to the name of your sheet and the refereces accordingly.

Excel Formula:
=UNIQUE(FILTER(Sheet5!$B:$B,Sheet5!$A:$A=$D$3))

My examples...
View attachment 116343View attachment 116345View attachment 116346

Also if you conditional formatting to column D, to add border if cell is not empty ( <>"" ) to keep the cell borders based on the selection.

Hello @sxhall, if the profile information is correct the formula @rasika_99 is looking for should be for Excel 2007...
 
Upvote 0
I don't know what formulas can be used in excel 2007, but try this, hopefully all the functions can support excel 2007.

Excel Formula:
=IFERROR(INDEX(B:B,SMALL(IF(A:A=F3,ROW(B:B),""),ROW(A1:A10))),"")

1725439728654.png
 
Upvote 0
hopefully all the functions can support excel 2007.
Although those functions re in 2007, but only 2021 & 365 support spill ranges, so it will need to be changed to a drag down formula.
 
Upvote 0
Although those functions re in 2007, but only 2021 & 365 support spill ranges, so it will need to be changed to a drag down formula.
Won't it work if you select the result range before entering the formula? I don't have 2007 anymore, but I think it might work.
 
Upvote 0
Yes but you would need to know how many rows were required. IMO it's better & simpler to just adjust the formula so it can be dragged down.
 
Upvote 0
Fair enough. You also need to know how many rows you have to drag down. But, adjusting the number of rows for the result is easier dragging down I guess.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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