提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何在Excel中应用相同的过滤器?

我们可能很容易应用Filter函数来过滤工作表中的数据,但有时您可能需要跨多个工作表进行过滤,这些工作表具有相同过滤条件的通用数据格式。 要逐一过滤它们会浪费很多时间,在这里,我可以引入一种简单的方法来一次解决它。

使用VBA代码将相同的过滤器应用于多个工作表


按照多个标准或其他特定条件过滤数据,例如按文本长度,区分大小写等。

Kutools for Excel超级过滤器 功能是一个强大的实用程序,您可以应用此功能来完成以下操作:

  • 用多个标准过滤数据; 按文本长度过滤数据;
  • 按大写/小写过滤数据; 筛选日期按年/月/日/周/季

DOC超filter1

Kutools for Excel:比200方便的Excel加载项,可以在60天免费试用。 下载并免费试用现在!


箭头蓝色右泡 使用VBA代码将相同的过滤器应用于多个工作表


例如,我有四张工作表,如下面的屏幕截图需要使用与产品= KTE一次相同的标准进行过滤。

doc过滤多张工作表1

没有直接的方法来筛选Excel中多个工作表中的数据,但是,以下VBA代码可以帮助您完成这项工作,请按照以下步骤操作:

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块,并将以下代码粘贴到 模块 窗口。

VBA代码:将相同的过滤器应用于多个工作表:

Sub apply_autofilter_across_worksheets()
'Updateby Extendoffice 20160623
    Dim xWs As Worksheet
    On Error Resume Next
    For Each xWs In Worksheets
        xWs.Range("A1").AutoFilter 1, "=KTE"
    Next
End Sub

3。 然后按 F5 运行此代码的关键是,KTE的所有产品一次都在所有工作表中被过滤,请参见屏幕截图:

doc过滤多张工作表2

注意:在上面的代码中,在这个 xWs.Range(“A1”)。AutoFilter 1,“= KTE” 脚本, A1 = KTE 表示您要过滤的列和标准,数字1是您根据过滤的列号,您可以将其更改为您的需要。 例如,如果要过滤大于50的顺序,则只需修改此脚本,如下所示: xWs.Range(“B1”)。AutoFilter 2,“> 50”.


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    berenice · 5 months ago
    how to eliminate filtered rows?
  • To post as a guest, your comment is unpublished.
    Sibi · 11 months ago
    How to use "Filter Between" Function, for the same multiple sheets?

    (Example: Time range)
  • To post as a guest, your comment is unpublished.
    Suyash · 11 months ago
    Can we use cell name like Product instead of A1 in : xWs.Range("A1").AutoFilter 1, "=KTE"
    I have different column and some names comes in different column.
    • To post as a guest, your comment is unpublished.
      Suyash · 11 months ago
      I have used filter in every sheet. And I want to change s.no from 1 2 3 serially in every sheet after filter.


      Please let me know if you have vba code for it
  • To post as a guest, your comment is unpublished.
    jarred · 1 years ago
    HI, does the super filter across the entire workbook automatically reapply whenever theres an update of the file?
  • To post as a guest, your comment is unpublished.
    Sebastian · 1 years ago
    Thank you for the code!! is there a way to change the "=KTE" to use a value from a List or Drop down list?
  • To post as a guest, your comment is unpublished.
    Matthew · 1 years ago
    Is there a way to change the "=KTE" part for each sheet with a contain filter that is based on the sheet's name?
  • To post as a guest, your comment is unpublished.
    Monika · 1 years ago
    Hi,


    How this works if Product column is presented in different places in other sheets ?


    In sheet1, it is A1 in sheet2 it is in B1 and in sheet3 it is A1 again ?

    Thanks,
    Monika
  • To post as a guest, your comment is unpublished.
    Mahesh · 1 years ago
    Is there any option to filter by colors?
  • To post as a guest, your comment is unpublished.
    Justin · 1 years ago
    Can I use this to filter pivot tables in multiple sheets if all the pivots tables are from same data source and set up using same criteria?
  • To post as a guest, your comment is unpublished.
    donovan · 1 years ago
    How can you use the result of the auto-filter to set the filter for each other sheet instead of using =(specific name)
  • To post as a guest, your comment is unpublished.
    Donovan Hubbart · 1 years ago
    How do execute if the filter is on a different column on each sheet?
  • To post as a guest, your comment is unpublished.
    Grace · 1 years ago
    Hi,


    My data is in Column E and when I apply this filter with Range("E1") it still filters column A


    How can I troubleshoot?
    Thanks
    • To post as a guest, your comment is unpublished.
      VBA · 1 years ago
      You just have to write the Column number in AutoFilter, in this case: xWs.Range("E1").AutoFilter 5,
  • To post as a guest, your comment is unpublished.
    KABILAN · 2 years ago
    while filtering single word in multiple sheets it does not shows filtered data....all datas are hided.pleace resolve this.
  • To post as a guest, your comment is unpublished.
    AHMAD KALBOUNEH · 2 years ago
    Dear,

    i want to filter more than one value, i used this xWs.Range("B1").AutoFilter 2, "=223AM", xlOr, "=113IR", xlOr, "=003IR" and it worked
    but when i increase the wanted values to >2 an error occurs.
    this command i use xWs.Range("B1").AutoFilter 2, "=223AM", xlOr, "=113IR", xlOr, "=003IR", xlOr, "=019IR", xlOr, "=311IR", xlOr, "=518ZA", xlOr, "=223AM", xlOr, "=592IR"


    thanks,
  • To post as a guest, your comment is unpublished.
    Guy · 2 years ago
    how do you apply this filter formula: to a range of sheets? i have a workbook that has data on the first 5 sheets, and the workbook has 200 sheets i only need the filter to be applied to sheet 6-200.
    Sub apply_autofilter_across_worksheets()
    'Updateby Extendoffice 20160623
    Dim xWs As Worksheet
    On Error Resume Next
    For Each xWs In Worksheets
    xWs.Range("A1").AutoFilter 1, "=KTE"
    Next
    End Sub
    • To post as a guest, your comment is unpublished.
      Cosmicbugaboo · 2 years ago
      Sub apply_autofilter_across_worksheets()

      Dim J As integer
      On Error Resume Next
      For J = 6 to Worksheets(worksheets.count)
      Thisworkbook.Sheets(J).Range("A1").Autofilter 1, "=KTE"
      Next
      End Sub