macro that cleans single the unblocked cell

  • Thread starter Thread starter Carlos V
  • Start date Start date
C

Carlos V

Hello to all the group, I have a book has formulates, I have the cell where
I write the data are unblocked and I have the book protected with password,
My question is since I make a macro that cleans single the unblocked cell?
 
Carlos,
Sub ijb1()
Cells(4, 4).ClearContents
End Sub

replacing Cells(4,4) with the address of the cells you need to clear

--
If I've mis-understood the question please tell me.

HTH

ijb

Remove nospam from my e-mail address to talk direct

Not MCSD, MVP, TLA, P&P, PCMCIA, etc just trying to help
 
You either have to unprotect that worksheet or protect it so the code can do
things that the user can't.

This example just unprotects the worksheet (you meant worksheet???) and does the
work and protects the worksheet when it's done.

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim myCell As Range
Dim myRng As Range

Set wks = ActiveSheet
With wks
.Unprotect Password:="hi"
Set myRng = .UsedRange
For Each myCell In myRng.Cells
If myCell.Locked Then
myCell.ClearContents
'mycell.value = ""
End If
Next myCell
.Protect Password:="hi"
End With
End Sub


If you have merged cells, use mycell.value = ""
If not the mycell.clearcontents is ok
 
Back
Top