Data Filter linking to cells

Swaroon

Active Member
Joined
Nov 18, 2005
Messages
288
Office Version
  1. 365
Hi,

I have a file containing 500+ rows of data, column H lists the programme agreement reference per row, out of the 500 rows, there might be 25 different agreement codes.

Can I enter a prog agreement number in a cell, and get the data filter funtion to reference the cell, therefore if I enter agreement AAA in cell A1, the macro will filter the 500 rows showing only those rows where the agreement is AAA ?

Ideally, I would like to be able to filter on up to 5 agreement numbers, these could be listed in cells A1:A5 ?

Any ideas........I haven't !
thanks
Steve
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi Swaroon:

Try this:
It will work with double click
Suppose your data located in D10:F500 & your agreements are in A1:A5 (it can be in any range)
Code:
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim FiltVal As String
    FiltVal = ActiveCell.Value
    Worksheets("Sheet1").AutoFilterMode = False
    Range("D10:F500").AutoFilter
    Selection.AutoFilter Field:=1, Criteria1:=FiltVal
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,704
Members
452,938
Latest member
babeneker

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