Guzzlr
Well-known Member
- Joined
- Apr 20, 2009
- Messages
- 982
- Office Version
- 2021
- Platform
- Windows
Hello
I have:
So I am trying to delete the two sheets above.
If I manually run the code with F8, the sheets delete.
However, when I install a button with sub ClearContents, the sheet of "Tech Description Report" is skipped...as if it is moving too fast.
So, I added a wait of 3 seconds to hope that it will "catch up" but it still skips over the sheet of "Tech Description Report". But again, if I manually move through the code, the sheet does delete.
Maybe instead of having two separate line areas for deleting...combine into one?
I'm curious why this is happening.
Thanks for the help
I have:
VBA Code:
Sub ClearContents()
Application.ScreenUpdating = True
Application.DisplayAlerts = False
'********* Delete Sheets **********
Sheets("NexGen Report Paste").Select
ActiveWindow.SelectedSheets.Delete
Application.Wait (Now + TimeValue("00:00:03"))
Sheets("Tech Description Report").Select
ActiveWindow.SelectedSheets.Delete
'Return to Template Tab
Sheets.Add.Name = "Tech Description Report"
Sheets.Add.Name = "NexGen Report Paste"
Sheets("NexGen Report Paste").Select
Range("A1").Interior.ColorIndex = 4
Range("A1").Select
Application.ScreenUpdating = False
Application.DisplayAlerts = True
End Sub
So I am trying to delete the two sheets above.
If I manually run the code with F8, the sheets delete.
However, when I install a button with sub ClearContents, the sheet of "Tech Description Report" is skipped...as if it is moving too fast.
So, I added a wait of 3 seconds to hope that it will "catch up" but it still skips over the sheet of "Tech Description Report". But again, if I manually move through the code, the sheet does delete.
Maybe instead of having two separate line areas for deleting...combine into one?
I'm curious why this is happening.
Thanks for the help