Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter data in a worksheet
#1
Example:

Sub FilterData()
    Dim filterRange As Range

    'Set the range to be filtered (assuming data starts from A1)
    Set filterRange = Range("A1").CurrentRegion

    'Apply filter to column A for values greater than 5
    filterRange.AutoFilter Field:=1, Criteria1:=">5"
End Sub

Explanation:

The code defines a subroutine named FilterData.
It declares a variable filterRange, which represents the range to be filtered. 
In this example, the range is set to the data starting from cell A1 using the CurrentRegion property.
The filterRange.AutoFilter method is used to apply a filter to the range.
Field:=1 specifies that the filter should be applied to the first column of filterRange (column A).
Criteria1:=">5" sets the filtering criteria to show only values greater than 5.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Messages In This Thread
Filter data in a worksheet - by Qomplainerz - 07-27-2023, 09:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy data to another worksheet Qomplainerz 0 799 07-27-2023, 11:24 AM
Last Post: Qomplainerz
  Concatenate data in columns Qomplainerz 0 711 07-27-2023, 11:01 AM
Last Post: Qomplainerz
  Create a pivot table based on data in a worksheet with VBA Qomplainerz 0 797 07-27-2023, 09:48 AM
Last Post: Qomplainerz
  Create a chart from data with VBA Qomplainerz 0 759 07-27-2023, 09:44 AM
Last Post: Qomplainerz
  Sort data in a range with VBA Qomplainerz 0 746 07-27-2023, 09:43 AM
Last Post: Qomplainerz
  Insert a new row and fill it with data in VBA Qomplainerz 0 698 07-27-2023, 09:11 AM
Last Post: Qomplainerz
  Add data validation to a cell with VBA Qomplainerz 0 680 07-27-2023, 09:10 AM
Last Post: Qomplainerz
  Protect and unprotect worksheet with VBA Qomplainerz 0 643 07-27-2023, 08:20 AM
Last Post: Qomplainerz
  Create a new worksheet and rename it with VBA Qomplainerz 0 648 07-27-2023, 08:14 AM
Last Post: Qomplainerz
  Copy data from one workbook to another with VBA Qomplainerz 0 681 07-27-2023, 08:02 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: