macro that cleans single the unblocked cell

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?
 
I

ijb

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
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top