相关疑难解决方法(0)

Worksheet类的ShowAllData方法失败

我注意到当自动过滤器已经打开时,我的VBA脚本不起作用.知道为什么会这样吗?

    wbk.Activate
    Set Criteria = Sheets("Sheet1").Cells(i, 1)

    Set rng = Sheets("Sheet1").Range(Cells(i, 2), Cells(i, 4))

    wb.Activate
    If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData 'remove autofilter, but it crashes on this line

    Selection.AutoFilter

    Range("$A$1:$BM$204").AutoFilter Field:=2, Criteria1:=Criteria.Value

    rng.Copy

    Range("$BC$2:$BE$204").SpecialCells(xlCellTypeVisible).PasteSpecial
Run Code Online (Sandbox Code Playgroud)

非常感谢

excel vba autofilter

31
推荐指数
4
解决办法
12万
查看次数

Excel 2013 VBA清除活动过滤器

我需要在运行某个宏之前清除工作表中的所有活动过滤器,如果有活动过滤器,此行可以正常工作

If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Run Code Online (Sandbox Code Playgroud)

但是,如果未选择过滤器,则返回错误

Runtime error '1004';
ShowAllData method of Worksheet class failed
Run Code Online (Sandbox Code Playgroud)

我从这个问题的答案得到了这个代码 Excel 2013 VBA清除所有过滤器宏

但是,如果没有过滤器处于活动状态,则该问题不能解释如何忽略该行.

如果没有应用当前有效的过滤器,如何忽略此行?

编辑

例如,所有列标题都已自动过滤,因此如果我的工作表被"女性"过滤,例如我需要在运行宏之前删除该过滤器,但是如果没有应用过滤器,则只需正常运行宏

excel vba excel-vba

7
推荐指数
2
解决办法
6万
查看次数

如何使用 xlwings 清除 Excel 中的筛选器?

我的团队使用 Sypder (Python) 中的 xlwings 将 Excel 表格转换为 CSV 格式。然而,当过滤表时,这会改变 CSV 输出。是否有 xlwings 命令可以清除活动 Excel 工作表中的过滤器?

VBA 中的类似命令是(来自Excel 2013 VBA 清除所有过滤器宏):

Sub Macro1()
    Cells.AutoFilter
End Sub
Run Code Online (Sandbox Code Playgroud)

python excel filter xlwings

4
推荐指数
1
解决办法
5823
查看次数

标签 统计

excel ×3

vba ×2

autofilter ×1

excel-vba ×1

filter ×1

python ×1

xlwings ×1