gleamng
Board Regular
- Joined
- Oct 8, 2016
- Messages
- 98
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Platform
- Windows
- MacOS
- Mobile
- Web
Good day everyone, sure you are all well.
Please kindly help me with this edited code, i got Run-time error 1004 - method delete of object _worksheet failed which highlight xWs.Delete
Please kindly help me with this edited code, i got Run-time error 1004 - method delete of object _worksheet failed which highlight xWs.Delete
VBA Code:
Sub DeleteSheets()
Dim xWs As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Worksheets
If xWs.Name <> "Dashboard" Then
xWs.Delete
End If
Next xWs
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub