KutoolsforOffice β€” One Suite. Five Tools. Get More Done.February Sale: 20% Off

How to filter data just by clicking cell content in Excel?

AuthorXiaoyangLast modified

In daily Excel tasks, efficient data filtering is crucial when analyzing large datasets or when you need to quickly isolate information based on specific criteria. Typically, Excel provides the standard Filter function, allowing users to select filter criteria manually from column headers. However, this method requires several clicks and can be less intuitive, especially when you want to filter data dynamically or based on selections not in column headers. In this article, we discuss practical ways to filter data simply by clicking a cell value. For example, with the dataset below, if you double-click cell A2, all rows matching the value in that cell are automatically filtered, instantly displaying the relevant data as shown in the screenshot.

 filter data just by clicking cell content


Filter data just by clicking a cell value with VBA code

VBA provides a remarkably efficient way to filter data by simply double-clicking on a cell value, saving time compared to the regular filter options. This method is suited for users who are comfortable enabling macros and want true one-click interactivity. Please follow the instructions below:

1. Assign a range name to your dataset. Select the entire data range, enter a name (such as mydata) in the Name Box above the grid, and press the Enter key. Naming the range ensures the VBA code can easily reference your table.

define a range name for the data range

2. Right-click the sheet tab where you want this interactive filtering. Choose View Code from the context menu. In the Microsoft Visual Basic for Applications window that appears, paste the following code into the worksheet's code area (not a regular module):

VBA code: Filter data by clicking cell value:

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Updateby Extendoffice
    Dim rgTable As Range
    Dim rgData As Range
    Dim xColumn As Integer
    On Error Resume Next
    Application.ScreenUpdating = False
    Set rgTable = Range("mydata")
    With rgTable
        Set rgData = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count)
        If Not Application.Intersect(ActiveCell, rgData.Cells) Is Nothing Then
            xColumn = ActiveCell.Column - .Column + 1
            If ActiveSheet.AutoFilterMode = False Then
                .AutoFilter
            End If
            If ActiveSheet.AutoFilter.Filters(xColumn).On = True Then
                .AutoFilter Field:=xColumn
            Else
                .AutoFilter Field:=xColumn, Criteria1:=ActiveCell.Value
            End If
        End If
    End With
    Set rgData = Nothing
    Set rgTable = Nothing
    Application.ScreenUpdating = True
End Sub

clcik View Code and paste the code into the module

Note: The code uses mydata as the range name for your data table. Make sure this matches the name you assigned. If you use a different name, update the code accordingly.

Since this macro responds to the worksheet's double-click event, it will only work if macros are enabled, and only on the sheet where you placed the code. The macro filters the data table based on the value of the cell you double-click, showing only matching rows. Double-click again to reset the filter.

3. After saving and closing the code window, return to your worksheet. Now, whenever you double-click any cell within the main data region, Excel will instantly filter and display only rows corresponding to the value you clicked, as demonstrated in the screenshot:

when double clicking any cell of the data range, its corresponding records will be filtered

If the filter does not apply as expected, check that macros are enabled, verify your data range includes column headers, and ensure "mydata" refers to the full area including headers. This method does not support undo using Ctrl+Z, so plan accordingly. If you wish to clear the filter, you can double-click the same value again or use the Clear Filter option from the ribbon.

This VBA approach is ideal when you need quick, repeated, and interactive filtering on structured datasets, such as logs, customer lists, or sales records. The main limitation is that it requires users to enable macros and have at least basic comfort with worksheet events. Advanced sharing or integration scenarios may need alternative solutions described below.


Excel Formula - Dynamically filter data by a selected cell value (no VBA)

This method uses built-in Excel formulas (such as FILTER) to create interactive, dynamic filtering based on a selected or manually entered value. It is suitable for users who want to avoid macros, need portability across workbooks, or are working in environments where VBA is not permitted. The FILTER function is available in Excel365, Excel2021, and Excel Online.

For example, suppose you have a data table in the range A1:C11 with headers, and you want to filter rows based on a value entered in cell E1.

1. In an empty cell where you want your filtered results to appear (e.g., G2), enter the following formula to filter rows by the value in E1 for the first column (A):

=FILTER(A2:C11, A2:A11=E1, "No results found")

This formula will show only the rows where the value in column A matches what you entered or selected in E1. If you want to filter based on another column, adjust the condition accordingly, such as B2:B11=E1.

2. Press Enter and the filtered results will populate automatically. Whenever you change E1, the output area updates instantly.

3. You can link E1 to a data validation dropdown list for click-and-select filtering. Simply go to Data > Data Validation, choose List, and point Source to your values. This makes it even easier to select filter criteria without typing.

Using the FILTER formula is highly dynamic and safe as it does not require enabling macros. However, it does not physically hide non-matching records in the original table and works only in supported Excel versions. For users with older Excel versions, consider the Advanced Filter feature (see below).

Troubleshooting: If you get a #CALC! or error message, check that your formula covers the correct ranges and that you are using a supported Excel version.

Tip: If your dataset is large, using dynamic arrays and formulas may impact workbook responsiveness, especially if real-time filtering is continuously recalculated.


Other Built-in Excel Methods - Use slicers or table filters for interactive filtering

Excel’s built-in Table Filters and Slicers provide a user-friendly way to interactively filter data with a single click, without writing code or formulas. This is especially helpful for dashboards and summary sheets where non-technical users need interactive capabilities.

To use this method, convert your range into a Table:

  1. Select your dataset and navigate to Insert > Table. Make sure "My table has headers" is checked and click OK.
  2. An interactive filter arrow appears on each table header. Click the arrow, select the value(s) you want, and Excel will filter the data accordingly.
  3. You can insert a Slicer for even easier point-and-click filtering: With your table selected, go to Table Design > Insert Slicer, choose the columns for which you want a slicer. Clicking entries in the slicer instantly filters table rows in view.

This approach empowers users to filter data visually and interactively, supporting multiple columns and instant filtering. Slicers can be formatted and moved freely for better dashboard design. If you have a PivotTable, slicers can be attached and even synchronized across multiple tables for unified filtering.

Some caveats are that slicers and table filters require the range to be formatted as a Table. Large datasets might cause slight lag, and only the visible rows are affected, not the underlying data.

Slicers are not supported in Excel for the web as of writing. Always confirm compatibility when sharing workbooks with others.


Conditional Formatting - Visually highlight records matching selected value

When you need to visually focus on, but not hide, records matching a specific value, Conditional Formatting is a quick solution. This method automatically highlights rows or cells containing the value you select or enter in a helper cell. It's useful for visually sifting through data and is well-suited for collaborative workbooks since it requires no code or formulas in cells.

Suppose you want to highlight all rows where the first column data matches a value entered in cell E1.

  1. Select your whole data range (e.g., A2:C11).
  2. Go to Home > Conditional Formatting > New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. Enter this formula (assuming A2 is the first row of data): =$A2=$E$1
  5. Click Format to set the fill or font formatting you want, then click OK in all dialogs.

Now, whenever you change E1, all matching rows or cells in your data are instantly highlighted, drawing your attention without removing or hiding other records.

This method is ideal when you need visual cues instead of actual data hiding, such as in collaborative environments or when presenting data to groups who need to see context. For actual data hiding or extraction, use one of the filtering methods above.

Limitations: Conditional formatting highlights only; it does not filter or hide other data. For visual-only applications, this is an easy, maintainable solution.

a screenshot of kutools for excel ai

Unlock Excel Magic with Kutools AI

  • Smart Execution: Perform cell operations, analyze data, and create chartsβ€”all driven by simple commands.
  • Custom Formulas: Generate tailored formulas to streamline your workflows.
  • VBA Coding: Write and implement VBA code effortlessly.
  • Formula Interpretation: Understand complex formulas with ease.
  • Text Translation: Break language barriers within your spreadsheets.
Enhance your Excel capabilities with AI-powered tools. Download Now and experience efficiency like never before!

More related articles:

How to change cell value by clicking on the cell?

How to sort column data by clicking on header in Excel?

Best Office Productivity Tools

πŸ€–Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |  Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |  Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

ExcelWordOutlookTabsPowerPoint
  • All-in-one suite β€” Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license β€” set up in minutes (MSI-ready)
  • Works better together β€” streamlined productivity across Office apps
  • 30-day full-featured trial β€” no registration, no credit card
  • Best value β€” save vs buying individual add-in