MAcro to Clear Cells

  • Thread starter Thread starter Glenn Robertson
  • Start date Start date
G

Glenn Robertson

Hi,

I have a macro that when pushed it will clear all the info
out of any cell that is un-protected on my worksheet. The
macro works fine until it comes across a merged cell then
I get the following error message :-

Run-time error '1004':
Cannot change part of a merged cell.

My macro is as follows :-

Sub test()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
End Sub

Can anybody help ?
 
Sub test()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If cell.Locked = False Then cell.MergeArea.ClearContents
Next
End Sub
 
Sorry Glenn I did not give a answer on this in the original thread
I am building a network at home and format all the PC's so I lost the thread
 
Back
Top