Skip to content

Instantly share code, notes, and snippets.

@discarn8
Created May 18, 2018 18:26
Show Gist options
  • Select an option

  • Save discarn8/de2c4db18be38844fa29f3e4912e8c6f to your computer and use it in GitHub Desktop.

Select an option

Save discarn8/de2c4db18be38844fa29f3e4912e8c6f to your computer and use it in GitHub Desktop.
EXCEL - Clear_sheets.vba
Option Explicit
Sub CLEARDATA()
On Error GoTo ErrHandler
Dim arrSHEETS As Variant
Dim wsheets As Variant
arrSHEETS = Split("Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,Golf,Hotel", ",")
Sheets("Errors").Range("A1:BBB20000").ClearFormats
Sheets("Errors").Tab.ColorIndex = xlColorIndexNone
Sheets("CSV").Tab.ColorIndex = xlColorIndexNone
For Each wsheets In arrSHEETS
Worksheets(wsheets).Range("A1:BBB20000").ClearContents
Worksheets(wsheets).Cells.ClearComments
Sheets(wsheets).Select
Cells(1, 1).Activate
Next wsheets
Sheets("CSV").Select
Cells(2, 1).Activate
Exit Sub
ErrHandler:
MsgBox "I'm sorry - there was an error performing this task."
Resume Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment