Hi all,
Is there a simple VBA code to clear contents for all worksheets in a excel workbook?
I have nearly 25-30 worksheets in a tool which need to be cleared before running the tool
Thanks in advance for the help
Hi all,
Is there a simple VBA code to clear contents for all worksheets in a excel workbook?
I have nearly 25-30 worksheets in a tool which need to be cleared before running the tool
Thanks in advance for the help
Always test code on backup copies of data.
Sub ClearContents() Dim ws As Worksheet For Each ws In Worksheets ws.UsedRange.ClearContents Next ws End Sub
Sub ClearContents() Dim ws As Worksheet For Each ws In Worksheets If Not (ws.Name = "FirstSheetToSkip" Or ws.Name = "SecondSheetToSkip" Or ws.Name = "ThirdSheetToSkip") Then ws.UsedRange.ClearContents End If Next ws End Sub