简体   繁体   中英

filter data in one excel sheet based on data in another excel sheet

I have two excel sheet.

Sheet 1 
Dept    Dept ID
X1  1550
X2  1551
X3  1552
X4  1553
X5  1554
X6  1555

Sheet 2 
Dept ID Office
1550    Sydney
1551    Darwin
1552    Melbourne
1553    Perth
1554    Perth
1555    Perth

What I want is to filter data on sheet 2 based on selection of Dept in sheet 1. Suppose I choose Dept X1 than only row in sheet 2 is shown as for Dept_id=1550.

I don't know much about VB script. I tried to use advance filter but couldn't figure it out.

Thanks in advance

It sounds like you first need to do an INDEX / MATCH formula to match all of the department Id's to Office locations.

=INDEX(Sheet2!B1:B7,MATCH(B2,Sheet2!A1:A7,0))

That would get everything on one sheet. It's easy to match 6 examples here but I'm assuming you need help with hundreds or thousands of lines, in which case you would autofill the formula down the column:

链接 1

Here's what 'Sheet2' looks like per your example data:

链接 2

Now that you've got everything on one page you can just filter it normally:

链接 4

Pick only the data you want:

链接 3

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM