Skip to content

Instantly share code, notes, and snippets.

@scorchio
Created December 19, 2013 11:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scorchio/8037669 to your computer and use it in GitHub Desktop.
Save scorchio/8037669 to your computer and use it in GitHub Desktop.
VBA example code for clearing a worksheet
Sub ClearSheet()
Dim sheetToClear As Worksheet
Set sheetToClear = ActiveSheet ' Replace this with the sheet reference
' Delete something specific...
' sheetToClear.Cells.ClearFormats
' sheetToClear.Cells.ClearContents
' sheetToClear.Cells.ClearHyperlinks
' ...or every kind of data in the cells
sheetToClear.Cells.Clear
End Sub
@WSwarm
Copy link

WSwarm commented Dec 19, 2013

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment