sduttonusa
New Member
- Joined
- Jan 13, 2016
- Messages
- 43
The past few years, I've used the following macro (which is stored in my PERSONAL xlb) to clear unlocked cells in my workbook:
Sub Clearem()
Dim xx As Worksheet
Dim yy As Range
For Each xx In ThisWorkbook.Worksheets
For Each yy In xx.UsedRange.Cells
If Not yy.Locked Then yy.ClearContents
Next
Next
End Sub
For some reason, it's not working anymore. I came across another macro and was wondering if it does the same exact thing:
Sub ClearUnlockedAllSheets()
Dim Cell As Range, Sht As Worksheet
For Each Sht In Worksheets
For Each Cell In Sht.UsedRange
If Cell.Locked = False Then Cell.Value = ""
Next Cell
Next Sht
End Sub
Sub Clearem()
Dim xx As Worksheet
Dim yy As Range
For Each xx In ThisWorkbook.Worksheets
For Each yy In xx.UsedRange.Cells
If Not yy.Locked Then yy.ClearContents
Next
Next
End Sub
For some reason, it's not working anymore. I came across another macro and was wondering if it does the same exact thing:
Sub ClearUnlockedAllSheets()
Dim Cell As Range, Sht As Worksheet
For Each Sht In Worksheets
For Each Cell In Sht.UsedRange
If Cell.Locked = False Then Cell.Value = ""
Next Cell
Next Sht
End Sub
Last edited: