Show All Data VBA

SDave

Board Regular
Joined
Aug 12, 2008
Messages
152
Office Version
  1. 365
Platform
  1. MacOS
Afternoon all,

I have the following code, which up until yesterday was working fine.

It now debugs on ShowAllData - Method "ShowAllData" of object worksheet failed (Runtime error 1004)

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim ws As Worksheet
    Dim msg As String, _
    orgWs As String
    Dim Ctrl As Office.CommandBarControl
 
    Application.ScreenUpdating = False
 
    For Each ws In Worksheets
    If ws.FilterMode Then ws.ShowAllData
    ws.PageSetup.PrintArea = ""
    Next ws
 
    For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
    Ctrl.Enabled = True
    Next Ctrl
    For Each Ctrl In Application.CommandBars.FindControls(ID:=22)
    Ctrl.Enabled = True
    Next Ctrl
 
    Sheets("TM_Feed").Visible = True
    Sheets("TM_Feed").Select
    Range("A3:L1002").ClearContents
    ActiveWindow.SelectedSheets.Visible = False
 
    Sheets("Important_Information").Select
    Range("A1").Select
 
    Application.ScreenUpdating = True
End Sub

Any ideas?!
 
This should work (albeit untested)

Code:
    For Each ws In Worksheets
    If ws.FilterMode Then 
         ws.unprotect Password:="HUBBA"
         ws.ShowAllData
         ws.PageSetup.PrintArea = ""
         ws.protect Password:="HUBBA"
    end if
    Next ws
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,215,194
Messages
6,123,569
Members
449,108
Latest member
rache47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top