VBA to filter columns and rows based on drop-down

Aaronawl

New Member
Joined
Sep 11, 2018
Messages
10
ly46pc
Picture of spreadsheet:
ly46pc
https://prnt.sc/ly46pc

Hi all,

I Would like to be able to filter the data shown based on a dropdown in D5.

The 3 options are the teams: Estate Planner, Advisor Team, Review Team (employee names have been blanked out for the image)

When a team is selected in D5 I would like only the columns E to X to show the relevant employees that are part of that team, At the moment I have got this to work using the code:

Code:
 Dim rCell As Range For Each rCell In Range("E9:X9")
 rCell.EntireColumn.Hidden = False
 Next rCell
 For Each rCell In Range("E9:X9")
 rCell.EntireColumn.Hidden = (rCell.Value <> Range("D5").Value)
 Next rCell

But I would also like the same code the filter columns A:C and hide rows 11:234 based on if the team specified in D5 appears in any of the range A11:C234 (currently the small unreadable text in A11:C234 are the teams)

There may be a better way to have this option (I would have liked to use Pivot table Slicers rather than a dropdown - as potentially this could select 2 teams data to be shown. Any help or suggestions are appreciated.

Thanks
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
The link you provided doesn't work....can you have another look at it please.
 
Upvote 0

Book1
ABCDEFGHIJKLMNOPQRSTUVWX
1
2
3
4
5Review Team
6
7
8Employee Name:Employee1Employee2Employee3Employee4Employee5Employee6Employee7Employee8Employee9Employee10Employee11Employee12Employee13Employee14Employee15Employee16Employee17Employee18Employee19Employee20
9Team:Estate PlannerEstate PlannerAdvisor TeamReview TeamAdvisor TeamAdvisor TeamReview TeamEstate PlannerAdvisor TeamAdvisor TeamAdvisor TeamAdvisor TeamReview TeamEstate PlannerAdvisor TeamEstate PlannerAdvisor TeamReview TeamReview TeamEstate Planner
10
11Advisor TeamReview TeamEstate PlannerFact Finds (2nds)
12Advisor TeamReview TeamEstate PlannerJan 19
13Advisor TeamReview TeamEstate PlannerFeb 19
14Advisor TeamReview TeamEstate PlannerMar 19
15Advisor TeamReview TeamEstate PlannerApr 19
16Advisor TeamReview TeamEstate PlannerMay 19
17Advisor TeamReview TeamEstate PlannerJun 19
18Advisor TeamReview TeamEstate PlannerJul 19
19Advisor TeamReview TeamEstate PlannerAug 19
20Advisor TeamReview TeamEstate PlannerSep 19
21Advisor TeamReview TeamEstate PlannerOct 19
22Advisor TeamReview TeamEstate PlannerNov 19
23Advisor TeamReview TeamEstate PlannerDec 19
24Advisor TeamReview TeamEstate PlannerTotal
25
26Advisor TeamReview TeamEstate PlannerPresentations (3rds)
27Advisor TeamReview TeamEstate PlannerJan 19
28Advisor TeamReview TeamEstate PlannerFeb 19
29Advisor TeamReview TeamEstate PlannerMar 19
30Advisor TeamReview TeamEstate PlannerApr 19
31Advisor TeamReview TeamEstate PlannerMay 19
32Advisor TeamReview TeamEstate PlannerJun 19
33Advisor TeamReview TeamEstate PlannerJul 19
34Advisor TeamReview TeamEstate PlannerAug 19
35Advisor TeamReview TeamEstate PlannerSep 19
36Advisor TeamReview TeamEstate PlannerOct 19
37Advisor TeamReview TeamEstate PlannerNov 19
38Advisor TeamReview TeamEstate PlannerDec 19
39Advisor TeamReview TeamEstate PlannerTotal
40
41Review Team4ths Attended
42Review TeamJan 19
43Review TeamFeb 19
44Review TeamMar 19
45Review TeamApr 19
46Review TeamMay 19
47Review TeamJun 19
48Review TeamJul 19
49Review TeamAug 19
50Review TeamSep 19
51Review TeamOct 19
52Review TeamNov 19
53Review TeamDec 19
54Review TeamTotal
55
56Review Team5ths Attended
57Review TeamJan 19
58Review TeamFeb 19
59Review TeamMar 19
60Review TeamApr 19
61Review TeamMay 19
62Review TeamJun 19
63Review TeamJul 19
64Review TeamAug 19
65Review TeamSep 19
66Review TeamOct 19
67Review TeamNov 19
68Review TeamDec 19
Report
 
Upvote 0
This will hide the affected columns, but I don't follow the question regarding the rows !!
They ALL appear to be required by the "review team"

Code:
Sub MM1()
 Dim lc As Integer, c As Integer
 lc = Cells(8, Columns.Count).End(xlToLeft).Column
 For c = lc To 5 Step -1
    If Cells(9, c).Value <> Cells(5, 4).Value Then
        Columns(c).EntireColumn.Hidden = True
    End If
 Next c
End Sub
 
Upvote 0
Sorry, it wasn't the best description.

All data on the screen is required by the Review Team, but the data continues down to row 234 - some of which isnt required when the Review Team is selected in cell D5 drop-down.

If cell D5 is changed to Advisor Team, I dont need to see the current data 4ths or 5ths attended.

Essentially, I need the VBA to filter the columns and the rows. Only showing data relevant to the team selected in D5.

Hopefully this is clearer, thank you for your help thus far
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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