Clearing Values in a Range under certain conditions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to clear values from myRange under either of the following conditions

If the cell doesn't contain a formula OR if the cell is locked.

I have the following CODE

For Each r In myRange
Debug.Print r.Row, r.Formula, r.locked

If r.Formula = No Then
r.ClearContents
End If
Next r

I see that r.formula returns No when there is a formula and r.locked returns
True or False.
 
For Each r In myRange
If Not r.HasFormula Or r.Locked Then
r.ClearContents
End If
Next r


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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

Back
Top