filter on sheet1 also filters sheet2 based on sheet1 filtered values

rjvr

New Member
Joined
Nov 16, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I have multiple sheets in a excel file and the Address sheet contains the columns: Postal Code, House, City and Employee sheet contains the columns: Name, Contact, House, Postal Code. I wish to filter my sheets so that I can find the employees from a particular City.

Address Sheet:

Postal CodeHouseCity
EC1V 9LT372 Old StreetLondon
NW3 6BT176 Finchley RoadLondon
M14 5TD6 Wilmslow Road, RusholmeManchester
YO1 9RA7-9 Clifford StreetYork

Employee Sheet:

NameContactHousePostal Code
Employee 1XXXXX-XXXXXX372 Old StreetEC1V 9LT
Employee 2XXXXX-XXXXXX176 Finchley RoadNW3 6BT
Employee 3XXXXX-XXXXXX6 Wilmslow Road, RusholmeM14 5TD
Employee 4XXXXX-XXXXXX7-9 Clifford StreetYO1 9RA

Filtered Address Sheet:

Postal CodeHouseCity
EC1V 9LT372 Old StreetLondon
NW3 6BT176 Finchley RoadLondon

Which will automatically filter the Employee Sheet also giving the below result:

NameContactHousePostal Code
Employee 1XXXXX-XXXXXX372 Old StreetEC1V 9LT
Employee 2XXXXX-XXXXXX176 Finchley RoadNW3 6BT

Thank you for the help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello,
I have multiple sheets in a excel file and the Address sheet contains the columns: Postal Code, House, City and Employee sheet contains the columns: Name, Contact, House, Postal Code. I wish to filter my sheets so that I can find the employees from a particular City.

Address Sheet:

Postal CodeHouseCity
EC1V 9LT372 Old StreetLondon
NW3 6BT176 Finchley RoadLondon
M14 5TD6 Wilmslow Road, RusholmeManchester
YO1 9RA7-9 Clifford StreetYork

Employee Sheet:

NameContactHousePostal Code
Employee 1XXXXX-XXXXXX372 Old StreetEC1V 9LT
Employee 2XXXXX-XXXXXX176 Finchley RoadNW3 6BT
Employee 3XXXXX-XXXXXX6 Wilmslow Road, RusholmeM14 5TD
Employee 4XXXXX-XXXXXX7-9 Clifford StreetYO1 9RA

Filtered Address Sheet:

Postal CodeHouseCity
EC1V 9LT372 Old StreetLondon
NW3 6BT176 Finchley RoadLondon

Which will automatically filter the Employee Sheet also giving the below result:

NameContactHousePostal Code
Employee 1XXXXX-XXXXXX372 Old StreetEC1V 9LT
Employee 2XXXXX-XXXXXX176 Finchley RoadNW3 6BT

Thank you for the help.
 
Upvote 0
The easiest way to do this is to use VLOOKUP to join your 2 sheets together.
First: add a new column on both sheets and create a unique join key by =CONCAT("House", "Postal Code"). However, on your "Adress" Sheet, make sure this column is on the left of the City column
Second: On your "Employee sheet", in an empty column use VLOOKUP("Join Key", 'Adress Sheet'$JoinKey:$City, 2, FALSE)
With this, you'll have all of the employees' info on the Employee Sheet and do not need the Filter sheet and can simply filter by City on the Employee Sheet to find all employees in the desired city.

Screen Shot 2021-11-17 at 10.03.48 PM.png
 
Upvote 0
Thank you for your answer, but is it possible to do it without adding columns to the Employee sheet?
 
Upvote 0
Thank you for your answer, but is it possible to do it without adding columns to the Employee sheet?
Thank you for your answer, but is it possible to do it without adding columns to the Employee sheet?
There’s a couple approaches:
1) Use the join key to do either index/match or vlookup the name, contacts from Employee sheet on to your Address sheet. Same result but the columns will be added to your Adress sheet instead of Employee sheet. However, you’ll still need to make a join key column on your Employee sheet.
2) make a copy of your employee sheet and follow the same procedure mentioned before. This way, you’ll preserve the original Employee sheet
 
Upvote 0
If you were looking for a VBA solution, then the following will do what you want. It assumes your headers on both sheets are in row 1 and that your data starts in column A. Firstly, put the following code in a standard module:

VBA Code:
Option Explicit
Sub CopyFilter() 
    Dim arr, lr As Long, i As Long, ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Sheets("Address")
    Set ws2 = Sheets("Employee")
    lr = ws1.Cells(Rows.Count, 1).End(xlUp).Row
    
    arr = ws1.Range("A2:A" & lr).SpecialCells(xlCellTypeVisible)
    arr = Application.Transpose(Application.Index(arr, 0, 1))
    
    For i = LBound(arr) To UBound(arr)
       arr(i) = CStr(arr(i))
    Next i
    
    With ws2.Cells(1, 1).CurrentRegion
       .AutoFilter 4, Array(arr), 7
    End With
End Sub

Secondly, you said you wanted this process to happen "automatically". That being the case, start by putting the following formula into a spare cell/column on the Address sheet:
Excel Formula:
=COUNTA(A:A)

Then, put the following code in the worksheet change code area of the Address sheet:
VBA Code:
Private Sub Worksheet_Calculate()
    CopyFilter
End Sub

Now, if you change the filter on the Address sheet (column A) - the same filter will be applied to column D on the Employee sheet.

Good luck!
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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