Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default VBA code to protect cells Outside a given range

hi there,
I need to write code allow the user to enter dato only on cells that are
unprotected. What I need is to protect cells outside a given range.
On a 6 x 6 matrix, where N=3, protect all cells on rows and columns 4,5,6
4,5. If N=2, protect all cells in rows and columns 3,4,5,6.

thank you in advance.
NeedHelp


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default VBA code to protect cells Outside a given range

I have assumed that your 6x6 range is named Matrix.....

Sub UnprotectMatrix()
Dim N As Integer
N = 3
With Range("Matrix")
.Parent.Unprotect
.Cells.Locked = True
.Columns(1).Resize(, N).Locked = False
.Parent.Protect
End With
End Sub

HTH,
Bernie
MS Excel MVP


"OMER" wrote in message
...
hi there,
I need to write code allow the user to enter dato only on cells that are
unprotected. What I need is to protect cells outside a given range.
On a 6 x 6 matrix, where N=3, protect all cells on rows and columns 4,5,6
4,5. If N=2, protect all cells in rows and columns 3,4,5,6.

thank you in advance.
NeedHelp




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default VBA code to protect cells Outside a given range

Thank You very much Bernie.
I made a slight change to it, since I needed to also protect rows 4,5,6.
This is how it ended up.

Sub UnprotectMatrix()
Dim N As Integer
N = 3
With Range("Matrix")
.Parent.Unprotect
.Cells.Locked = True
.Resize(N, N).Locked = False
.Parent.Protect
End With
End Sub

Again, thanks



"Bernie Deitrick" wrote:

I have assumed that your 6x6 range is named Matrix.....

Sub UnprotectMatrix()
Dim N As Integer
N = 3
With Range("Matrix")
.Parent.Unprotect
.Cells.Locked = True
.Columns(1).Resize(, N).Locked = False
.Parent.Protect
End With
End Sub

HTH,
Bernie
MS Excel MVP


"OMER" wrote in message
...
hi there,
I need to write code allow the user to enter dato only on cells that are
unprotected. What I need is to protect cells outside a given range.
On a 6 x 6 matrix, where N=3, protect all cells on rows and columns 4,5,6
4,5. If N=2, protect all cells in rows and columns 3,4,5,6.

thank you in advance.
NeedHelp




.

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
Password Protect Specific Range Of Cells trip_to_tokyo[_3_] Excel Discussion (Misc queries) 6 October 5th 09 07:26 PM
How do I protect cells or a range of cells in excel spreadsheet? Abundance Excel Worksheet Functions 1 July 28th 09 11:03 PM
Protect/Restrict usage of a range of cells. Sri Harsha[_2_] Excel Discussion (Misc queries) 2 February 24th 09 12:03 PM
Hlp! Protect Cells in Dynamic Range dee Excel Discussion (Misc queries) 0 November 28th 07 03:07 PM
is there a way to protect a range of cells on a worksheet? vevans Excel Discussion (Misc queries) 1 February 17th 05 05:30 PM


All times are GMT +1. The time now is 09:13 AM.

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"