简体   繁体   English

筛选Excel数据集时ShowAllData失败

[英]ShowAllData fails when excel data set is filtered

I have an ETL file that has suddenly stopped working on the ShowAllData command. 我有一个ETL文件,该文件突然停止使用ShowAllData命令。 In previous loops, the data IS being filtered. 在以前的循环,数据过滤。

Givens: 吉文斯:

wkstSourceSheet is established in another module as the sheet that contains oSourceTable which is the originating table of data and/or scrubbed data to be uploaded. wkstSourceSheet在另一个模块中作为包含oSourceTable的工作表建立,该表是要上传的数据和/或清理后的数据的原始表。 The steps are contained in functions, grouped logically by module. 这些步骤包含在功能中,按模块按逻辑分组。 All local controls are contained in the Local_Controls module. 所有本地控件都包含在Local_Controls模块中。

Loop Steps 循环步骤

  • Remove any Sorts & Filters on Data (it is on 2nd loop when this fails) 删除数据上的所有排序和筛选器(失败时将在第二个循环中)
  • Apply new Sorts & Filters 应用新的排序和过滤器
  • Save Destination File if one is open and destination file is different for this loop 如果已打开目标文件并且此循环的目标文件不同,则保存目标文件
  • Open Destination File if needed 如果需要,打开目标文件
  • Clear applicable data from Destination 从目的地清除适用的数据
  • Paste new data to Destination 将新数据粘贴到目标
  • Clear some variables 清除一些变量
  • Loop

Code

If wkstSourceSheet.FilterMode = True Then
    wkstSourceSheet.ShowAllData
End If

I've been able to get a workaround by replacing it with this 我已经可以通过将其替换为解决方法

If wkstSourceSheet.FilterMode = True Then
    oSoureSheet.Range.Autofilter
    oSoureSheet.Range.Autofilter
End If

However, I'm trying to figure out why it would fail when the data is clearly filtered. 但是,我试图弄清楚为什么当对数据进行明确过滤时它会失败。

(I would write this as a comment if I could... but I don't have enough reputation yet) (如果可以的话,我会将其写为评论...但是我还没有足够的声誉)

Could you be having a problem with the two different types of Autofilters that Excel has? 您可能对Excel具有的两种不同类型的自动筛选器有疑问吗?

One for simple Worksheet ranges, the other for ListObjects (Excel "tables"). 一个用于简单的工作表范围,另一个用于ListObjects(Excel“表”)。

If there was manual user interaction with the worksheet (not just your code running), a user might have started the filters in two different ways... 如果用户手动与工作表交互(而不仅仅是运行代码),则用户可能已经以两种不同的方式启动了筛选器...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM