View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Selecting only unlocked cells to clear

Hi Randy,

I am not aware of any method of selecting unlocked cells, so I would try
something like:

''===========================
Public Sub ClearUnlockedCells()
Dim rcell As Range
Dim rng As Range
Dim CalcMode As Long

Set rng = ActiveSheet.UsedRange '<<======== CHANGE

With Application
.ScreenUpdating = False
CalcMode = .Calculation
.Calculation = xlManual
End With

For Each rcell In rng.Cells
If rcell.Locked = False Then
rcell.ClearContents
End If
Next rcell

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub
'<<===========================


---
Regards,
Norman



"RAP" wrote in message
...
Hello,
Can anyone give me the VB code to select all the unlocked-only cells on a
page or in a defined range, to clear them?

Thanks,
Randy