Protecting non contiguous cells

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

Guest

I am trying to protect all cells in a range with a value >0 so that users can
only input into the non blank cells in the range.

I've tried this

Sub test()

Range("A2:I10").Select
If Value = 0 Then
Cells.Locked = False
End If

End Sub

but it Unlocks all cells on the Worksheet so I'm obviously doing something
very wrong.

I'd be grateful for some help please
 
Hi

try

sub test()
For Each c In Range("A2:I10")
If c.Value <> 0 Then
c.Locked = False
End If
Next
end sub

bit confused about which cells you want to protect - so let me know if the
above gives you what you want.

Cheers
JulieD
 
Thanks a lot for the replies. Julie's solution modified to "If c.Value = 0
Then" works a treat. Thanks again
 

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