Been trying a bunch of things but haven't come across an easy solution to this.
I have a sheet, Sheet A, which has, among others, a column called "City". I would like to be able to filter Sheet A along this City column. However, I want to be able to filter Sheet A based off the value of a cell in Sheet B. Essentially, I would like to be able to replicate the filter button in Sheet A City column and put it in Sheet B and be able to toggle the filter in Sheet B. I do not want to extract the data from Sheet A; I want Sheet A to be filtered.
Sheet A
City
Jamestown
Cape-Town
Hong Kong
Hong Kong
Sheet B
Hong Kong
Results in:
Sheet A
City
Hong Kong
Hong Kong
Put this code in the ThisWorkBook tab in VBA:
Private Sub workbook_Sheetchange(ByVal ws As Object, ByVal target As Range)
If target.Address = "$A$2" And ws.Name = "Sheet7" Then
Sheets("Sheet6").Range("A2:A6").AutoFilter field:=1, Criteria1:=Sheets("Sheet7").Range("A2"), VisibleDropDown:=True
End If
If Sheets("Sheet7").Range("A2") = "" Then
Sheets("Sheet6").ShowAllData
End If
End Sub
[
[
[
[
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.