• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 40
  • Last Modified:

how can i restrict modification/change of certain ranges in a worksheet with VBA

I need help with a code.  

basically,

the code should not allow user to modify any values into the followings ranges of Sheet("Data")

the only modification should be allowed by the Sub procedure that writes values into these cells that procedure name is Macro500

i googled to find the worksheet change event that restricts but i could not find something useful.

A33:B34
A38:B39
A15:B16
A21:B28
D15:K17
C21:K30
D32:K35
C38:K40
B6:C9
0
Flora
Asked:
Flora
1 Solution
 
Rgonzo1971Commented:
Hi,

this line protect the worksheet but letting vba modifying it
Workshe

Open in new window

et.Protect "Password", UserInterfaceOnly := True

Open in new window

eg.
Sheets("Sheet1").Protect "PW", UserInterfaceOnly := True

Open in new window

but first you have to lock the ones you don't want to be modified
Worksheets("Sheet1").Range("A33:B34,A38:B39,A15:B16,A21:B28,D15:K17,C21:K30,D32:K35,C38:K40,B6:C9").Locked = True

Open in new window

Regards
0
 
FloraAuthor Commented:
thanks very much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now