Code clear contents

Solved/Closed
MONI - 20 Jun 2010 à 10:19
 MONI - 20 Jun 2010 à 11:12
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 28 January 2010 Status Contributor Last seen 5 May 2022 766
20 Jun 2010 à 10:35
why not try
cell = ""
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.
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
20 Jun 2010 à 11:01
No, I meant to say
instead of
Cell.ClearContents

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

MONI