Code clear contents

Solved/Closed
MONI - Jun 20, 2010 at 10:19 AM
 MONI - Jun 20, 2010 at 11:12 AM
Hello,

I'm using this code to clear contents in a spreadsheet:

Sub clearunprotectedcells()
Dim cell As Range
Range("A12:F14").Select
For Each cell In Selection
If cell.Locked = False Then
cell.ClearContents
End If
Next
End Sub

The code works if I do not use merged cells, is there any away i ca modify my code to clear contents even if i have some merged cells.

Thanks


3 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jun 20, 2010 at 10:35 AM
why not try
cell = ""
0
Do you mean trying this cell = "" instead of cell.Locked = False Then, eventhough I have to clear the contents of just certain cells?

Thanks

MONI.
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jun 20, 2010 at 11:01 AM
No, I meant to say
instead of
Cell.ClearContents

Try
cell = ""
0
Thank a lot it worked.... Yuhu....

MONI
0