filter a formatted table based on value in another cell

coffeenazi

New Member
Joined
Aug 17, 2010
Messages
17
Office Version
  1. 365
Platform
  1. Windows
I have a formatted table named Table1.

I have a validated drop-down list in cell B2.

Is there a way to link the value in B2 to Table1 so that the table is filtered by column 4 to the result of the value in cell B2? For example, the user would select "Apples" from the list in B2, and Table1 would automatically be filtered to only show rows with "Apples" in column 4.

I've searched and tried numerous threads with no success so far, hoping you can help me.

thanks in advance!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi,

Can you please provide some dummy data and expected outcome for more clarity.
 
Upvote 0
I can't post attachments, sorry. but it would look like this.

Product:ApplesResult: Table1 after "Apples" selected from cell B2
MonthSiteCountProductMonthSiteCountProduct
JanSite 110ApplesJanSite 110Apples
FebSite 25OrangesAprSite 47Apples
MarSite 36PearsJulSite 74Apples
AprSite 47ApplesOctSite 1010Apples
MaySite 59OrangesJanSite 137Apples
JunSite 63PearsAprSite 164Apples
JulSite 74Apples
AugSite 88Oranges
SepSite 91Pears
OctSite 1010Apples
NovSite 115Oranges
DecSite 126Pears
JanSite 137Apples
FebSite 149Oranges
MarSite 153Pears
AprSite 164Apples
MaySite 178Oranges

<colgroup><col span="3"><col><col span="5"></colgroup><tbody>
</tbody>
 
Upvote 0
I have a formatted table named Table1.
I have a validated drop-down list in cell B2.
Is there a way to link the value in B2 to Table1 so that the table is filtered by column 4 to the result of the value in cell B2? For example, the user would select "Apples" from the list in B2, and Table1 would automatically be filtered to only show rows with "Apples" in column 4.
I've searched and tried numerous threads with no success so far, hoping you can help me.
thanks in advance!

You need something like this:

af978c2978052348d90cdb3384f7b3a0.jpg




Put the following code in the events of your sheet:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address(0, 0) = "[COLOR=#0000ff]B2[/COLOR]" Then
        ActiveSheet.ListObjects("Table1").Range.AutoFilter [COLOR=#0000ff]Field:=4[/COLOR], Criteria1:=Target.Value
    End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0
Thanks Dante, but I think that's a bit too technical for my audience. I'm hoping to find a way to run the macro on the cell change, or at the most for the user to click a button to activate it.

I need to share this workbook to a wide audience of different skill levels, so it needs to be quite foolproof.
 
Upvote 0
Thanks Dante, but I think that's a bit too technical for my audience. I'm hoping to find a way to run the macro on the cell change, or at the most for the user to click a button to activate it.

I need to share this workbook to a wide audience of different skill levels, so it needs to be quite foolproof.

I almost guess the real example.
If you want it to work automatically you must put the macro in the events of the sheet. Before thinking about the future, did you try my code?

You must explain other things.
Is it really a table?
Or are they just data in a range of cells?


In what row is the header?
Where do you want the results in the same table or in another part of the sheet?
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,052
Latest member
Fuddy_Duddy

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