data filters

aarti_rto

New Member
Joined
Nov 29, 2019
Messages
49
Office Version
  1. 2016
Platform
  1. Windows
  2. Web
Hello Experts,

i have below data , "Name , Department & salary".

i need your help to apply filter in "D" with dropdown for Department i.e. if i select HR then below table should display only HR related details..


D
ABC
NameDepartmentSalary
ABCSCM
193​
SADHR
418​
DSGFGFHR
697​
DSAFDSGFSCM
614​
SAFHR
258​
AFDSFI
136​
ADFSCM
273​
GFFI
753​
RETSCM
119​
ETSCM
786​
ETRFI
286​
RYTFI
431​
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
aarti let's get the ball rolling. Now usually this will generate more questions than answers, but we need to start somewhere. So is this what you had in mind.



22-02-08.xlsx
ABCDEF
1NameDepartmentSalaryDepartmentNameSalary
2ABCSCM193FIAFDS136
3SADHR418GF753
4DSGFGFHR697SCMETR286
5DSAFDSGFSCM614HRRYT431
6SAFHR258FI  
7AFDSFI136  
8ADFSCM273  
9GFFI753  
10RETSCM119  
11ETSCM786  
12ETRFI286  
13RYTFI431  
Data
Cell Formulas
RangeFormula
E2:E13E2=IFERROR(INDEX($A$2:$A$13,SMALL(IF($B$2:$B$13=$D$2,ROW($D$1:$D$12)),ROWS($D$1:D1))),"")
F2:F13F2=IFERROR(INDEX($C$2:$C$13,SMALL(IF($B$2:$B$13=$D$2,ROW($D$1:$D$12)),ROWS($D$1:D1))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Data Validation
CellAllowCriteria
D2List=$D$4:$D$6
 
Upvote 0
hi,
thank you for the reply , but i do not wish to create separate columns i.e. E & F.
i need the data to be filtered in same "A to C" range when filter applied in D .is it possible?
 
Upvote 0
Perhaps you mean this instead?

D1 has a Data Validation drop-down where you choose a Department.
A1:C?? has been manually set up with AutoFilter.

aarti_rto.xlsm
ABCD
1NameDepartmentSalary
2ABCSCM193
3SADHR418
4DSGFGFHR697
5DSAFDSGFSCM614
6SAFHR258
7AFDSFI136
8ADFSCM273
9GFFI753
10RETSCM119
11ETSCM786
12ETRFI286
13RYTFI431
14
Sheet1
Cells with Data Validation
CellAllowCriteria
D1ListFI,HR,SCM


You can then try this Worksheet_Change event code to filter/unfilter as cell D1 is changed. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test.
4. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm).

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("D1")) Is Nothing Then
    If IsEmpty(Range("D1").Value) Then
      ActiveSheet.AutoFilter.Range.AutoFilter Field:=2
    Else
      ActiveSheet.AutoFilter.Range.AutoFilter Field:=2, Criteria1:=Range("D1").Value
    End If
  End If
End Sub

Here is the sheet after I have chosen a value from the D1 drop-down.

aarti_rto.xlsm
ABCD
1NameDepartmentSalaryHR
3SADHR418
4DSGFGFHR697
6SAFHR258
14
Sheet1
Cells with Data Validation
CellAllowCriteria
D1ListFI,HR,SCM
 
Upvote 0
aariti because you can never have too many solutions, let's look at this one.

First make sure you select in the range, then select the Insert tab, then select Table

filter 2.png


Now you should see Create Table. Make sure My table has headers is checked.

filter 3.png


Now you have a table you can filter. Note Table Design if you want to change colors.
filter 4.png


When you click the down arrow you get to select which department you want.
filter 5.png



Here is my choice. Note Department has the filter.
filter.png
 
Upvote 0
hi,
thank you for the reply , but i do not wish to create separate columns i.e. E & F.
i need the data to be filtered in same "A to C" range when filter applied in D .is it possible?
Perhaps you mean this instead?

D1 has a Data Validation drop-down where you choose a Department.
A1:C?? has been manually set up with AutoFilter.

aarti_rto.xlsm
ABCD
1NameDepartmentSalary
2ABCSCM193
3SADHR418
4DSGFGFHR697
5DSAFDSGFSCM614
6SAFHR258
7AFDSFI136
8ADFSCM273
9GFFI753
10RETSCM119
11ETSCM786
12ETRFI286
13RYTFI431
14
Sheet1
Cells with Data Validation
CellAllowCriteria
D1ListFI,HR,SCM


You can then try this Worksheet_Change event code to filter/unfilter as cell D1 is changed. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test.
4. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm).

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("D1")) Is Nothing Then
    If IsEmpty(Range("D1").Value) Then
      ActiveSheet.AutoFilter.Range.AutoFilter Field:=2
    Else
      ActiveSheet.AutoFilter.Range.AutoFilter Field:=2, Criteria1:=Range("D1").Value
    End If
  End If
End Sub

Here is the sheet after I have chosen a value from the D1 drop-down.

aarti_rto.xlsm
ABCD
1NameDepartmentSalaryHR
3SADHR418
4DSGFGFHR697
6SAFHR258
14
Sheet1
Cells with Data Validation
CellAllowCriteria
D1ListFI,HR,SCM

Thank you...
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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