Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Protecting non contiguous cells

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Protecting non contiguous cells

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


"nospaminlich" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Protecting non contiguous cells

Thanks a lot for the replies. Julie's solution modified to "If c.Value = 0
Then" works a treat. Thanks again
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Protecting non contiguous cells

you're welcome and thanks for the feedback

"nospaminlich" wrote in message
...
Thanks a lot for the replies. Julie's solution modified to "If c.Value =
0
Then" works a treat. Thanks again





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Protecting non contiguous cells

You might want to test empty cells with c.value ="".

"JulieD" wrote:

you're welcome and thanks for the feedback

"nospaminlich" wrote in message
...
Thanks a lot for the replies. Julie's solution modified to "If c.Value =
0
Then" works a treat. Thanks again




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-contiguous cells Kokomojo Excel Discussion (Misc queries) 2 November 6th 07 04:09 PM
counting cells that are 0 in a range of non-contiguous cells Mark Excel Worksheet Functions 9 March 14th 07 02:45 PM
XIRR and Non Contiguous Cells John Taylor Excel Discussion (Misc queries) 2 August 2nd 06 12:41 AM
How do I count non-contiguous cells? broush Excel Worksheet Functions 5 May 30th 06 11:16 PM
Testing for contiguous cells jamieuk Excel Programming 2 January 8th 04 05:23 PM


All times are GMT +1. The time now is 12:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"