Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Protecting Select Cells

Posted on 2014-01-30
8
Medium Priority
?
219 Views
Last Modified: 2014-03-06
Hi All,

I have a workbook, in which I need to protect a few specific cells. When I tried locking it through the protect sheet/workbook option, it kills the vba which powers other functions.

I tried using the following code..

Sheets("Sheet1").UnProtect Password:="MyPassword"
...
Your code
...
Sheets("Sam").Protect Password:="MyPassword"

But unfortunately, I think I placed the code in the wrong area.

I need to protect:c2, c11:c138, e11:138

**The VBA project is password protect but its blank just hit ok.

Thanks,
test-1-30-14.xlsm
0
Comment
Question by:J_Drake
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 49

Accepted Solution

by:
Martin Liss earned 672 total points
ID: 39822193
Try protecting this way instead.

        Worksheets("Sam").Protect Password:="Password", Userinterfaceonly:=True, DrawingObjects:=False
0
 
LVL 31

Assisted Solution

by:gowflow
gowflow earned 664 total points
ID: 39822238
First of all you refer to
Sheets("Sam").Protect Password

and you don't have a sheet called Sam

then
what sheet you want to protect
c2, c11:c138, e11:138
I assume it is sheet Action Register.

If it is the case then you should think differently and decide what are the cells you want to Unlock !! as by default the whole worksheet is locked when you protect a worksheet reason why your code is bugging as it is hitting a locked cell that you are maybe changing by code and if the sheet is locked then it blocks.

I suggest the following:

1) You just unlock all the cells that you want the user to have access to and this point to the cell or group of cells and hit right click format cell protection and untick Locked.

2) In all the code that access this sheet (I did not go thru the code but if you want me to just lead me to what are the routines that affect this sheet)

3) so in all these routines you should have in the beging of the routine
sheets("Action Register").Unprotect Password:="MyPassword"
...
your code for the routine
and at the end
sheets("Action Register").protect Password:="MyPassword"

this way when the code runs it will run with unlocked sheet and make changes freely.

4) You need to make sure that in your Workbook_Open event you have:
sheets("Action Register").protect Password:="MyPassword"
so it Protect the worksheet upon opening the workbook.

Pls let me know if you need specific attendance on this code and where.
gowflow
0
 
LVL 22

Assisted Solution

by:spattewar
spattewar earned 664 total points
ID: 39822295
Please note that if you are using MartinLiss's solution you need to make sure that you put it in the workbook open event. Because the userinterface protection does not get saved when you save the workbook.

This is the best way to do it if you want the VBA code to do its stuff but prevent manual input on the sheet.

Hope it helps.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:gowflow
ID: 39827998
any chance to have tried out the proposed solution ?
gowflow
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39842746
Have any of the above helped you?
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39908811
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question