Filter table based on cell input

jtmarsh123

New Member
Joined
Jun 15, 2015
Messages
4
Good morning everyone,

I have gone through several forums and tried several VB codes but I just can't get the VB code to work.

Problem:
I am trying to filter a table based on a drop down selection.
example:
I have a drop down list in cell B1 with the following options - Sales A, Sales B, Sales C
I have a table/range A5:F14

RefC1C2SalesSizeProduct
1
100101Sales A2
A
2200102Sales B4B
3300103Sales C6C
4400104Sales A8A
5500105Sales B10B
6600106Sales C12C
7700107Sales A14A
8800108Sales C16C
9900109Sales B18B

<tbody>
</tbody>

When I select an input from the drop down list in B1 - I would like the above table to filter on D5 (Sales) and display the results.

Can anyone please assist?

Kindest regards,

Jtmarsh
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
BTW this is the code I've tried to use:


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Filter Column D based on value in B1, Criteria ">="
   If Target.Address = "$B$1" Then
       ActiveSheet.Range("$A$5:$F$14").AutoFilter _
               Field:=4, Criteria1:=">=" & Range("B1")
   End If
End Sub
 
Upvote 0
Got it to work. The issue was a slight formula correction. Needed to make the Criteria1 "equal" instead of "greater than and equal too".

Hope this helps.
Regards


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Filter Column D based on value in B1, Criteria ">="
   If Target.Address = "$B$1" Then
       ActiveSheet.Range("$A$5:$F$14").AutoFilter _
               Field:=4, Criteria1:=">=" & Range("B1")
   End If
End Sub
[/QUOTE]



BTW this is the code I've tried to use:


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Filter Column D based on value in B1, Criteria ">="
   If Target.Address = "$B$1" Then
       ActiveSheet.Range("$A$5:$F$14").AutoFilter _
               Field:=4, [COLOR=#ff0000]Criteria1:="="[/COLOR] & Range("B1")
   End If
End Sub
 
Upvote 0
Okay so now I have another issue. I am trying to filter on two columns with two different reference cells. However when I try, the first filter is always replaced by the second.
For example (from above):
I have a drop down list in cell B1 with the following options - Sales A, Sales B, Sales C
I have another drop down list in cell B3 with the following options - 2, 4, 6, 8, 10, 12, 14

I want to be able to filter my table with unique values entered from B1 and B3 - so that I can filter on the Sale and Size.

Any ideas?
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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