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
LVL 6
FloraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FloraAuthor Commented:
thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.