Thread: Clear Contents
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.setup
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default Clear Contents

Hi Paul

This macro clear the contents of all unlocked cells in all sheets in the
active workbook.

You can insert a button on a sheet which can call this macro.

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range
For Each sh In ThisWorkbook.Sheets
For Each cell In sh.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
Next
End Sub

Regards,
Per

"gibbylinks" skrev i meddelelsen
...
I have several sheets in one workbook I use for generating invoices. Is
there
a quick way to clear them (they have different setups) leaving the
formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul