View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dick Minter[_2_] Dick Minter[_2_] is offline
external usenet poster
 
Posts: 6
Default clearing unlocked fields on a protected sheet

How do you deal with merged cells? When the indicated cell is merged with
another, an error occurs. Would it be better to use a Userform with text box
objects?

DM

"STEVE BELL" wrote:

Put this in your code
replace
MsgBox cel.Address
with your code

To clear the cel use
cel.ClearContents

It is not necessary to unprotect if you are only changing the
unprotected cells.
==========================
Dim cel As Range, rng As Range

Set rng = ActiveSheet.Range("A1:A10")

For Each cel In rng
If cel.Locked = False Then
MsgBox cel.Address
End If
Next
=============================

--
steveB

Remove "AYN" from email to respond
"Dick Minter" wrote in message
...
I know that my cmd button code can unlock a worksheet, then step through a
list of named ranges to clear, but is there a better way, say using "For
each...next" to step trhough each cell in a named range to test for the
"unlocked" cells, then clearing? Can you address each cell as a range in
a
collection of ranges using For...each?

DM