VBA Unfilter range

前端 未结 2 1463
情歌与酒
情歌与酒 2021-01-12 22:21

I am using this code:

Sheets(\"Sheet1\").AutofilterMode = False

to unfilter the data in an Excel sheet using VBA (the point is to clear al

相关标签:
2条回答
  • 2021-01-12 22:55

    The ShowAllData will work only if your sheet has a filter, otherwise it will break. I found that you can create a function from this with On Error Resume Next and it should work in all cases:

    Sub ShowAllData()
    On Error Resume Next
    Worksheets("Sheet1").ShowAllData
    
    End Sub
    

    Then call function from your main sub:

    Sub Main()
    
    ShowAllData
    
    End Sub
    
    0 讨论(0)
  • 2021-01-12 23:04

    Use Worksheets("Sheet1").ShowAllData instead. See http://msdn.microsoft.com/en-us/library/office/bb178108%28v=office.12%29.aspx.

    0 讨论(0)
提交回复
热议问题