+ Reply to Thread
Results 1 to 14 of 14

run time error 1004, cell or chart is protected.

  1. #1
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    run time error 1004, cell or chart is protected.

    I get run time error 1004 when I click on a cell in a worksheet Attachment 154599
    The shhet is not protected nor is the cell locked so don't understand why I get this error. When I click on debug then the following comes up The line marked with[*] is highlighted yellow
    Please Login or Register  to view this content.
    Anyone have a solution or suggestion.

    Thanks
    Last edited by ndtsteve; 05-08-2012 at 12:05 PM.

  2. #2
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: run time error 1004, cell or chart is protected.

    Can you post the workbook?

  3. #3
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    Attached..........

    Problem occours when selecting Y or N in drop down when answering Number of runs required. on Main Data sheet

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: run time error 1004, cell or chart is protected.

    dude, cost summary is protected in the attachment. Find the password for that and unprotect it in the VBA

    worksheets("Cost Summary").unprotect ("passwor here")
    YOUR CODE HERE, then reprotect if needed.
    worksheets("Cost Summary").protect("password here")
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  5. #5
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    Sorry, my mistake........here it is unprotected, but only was protected in Protect sheet, not in vba.
    Not sure how to in vba, even tho you gave code. I need sheet to be mostly protected but certain cells (highlighted yellow on maion data sheet) need to be unprotected so that data can be entered.

  6. #6
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: run time error 1004, cell or chart is protected.

    Ok. Glad you mentioned that. I have 2 answers related to this:

    1) If you only plan to have the macro access certain areas of the sheet, you can allow those ranges to be edited. This is likely what you need.

    To set up allowed ranges on a protected sheet:

    Review tab>Allow Users to Edit Ranges
    Basically you name the range, and select the allowed cells from the sheet (if you have trouble doing this see the attachment).

    Then you protect the sheet and give it a password.


    2) If a macro needs to adjust a protected cell/range (anything that you have NOT told the spreadsheet is allowed for editing) THEN:

    You must unprotect the sheet before running the macro. The easiest way to do that is with the code, because then the user doesn't have to be aware of the password (because they could then just do whatever they want which defeats the whole idea) AND you get the protection. Usually i'll do this -- this works no matter how the sheet was protected (either "by hand" or "by Macro")

    Worksheets("sheet name here").unprotect password:="password here" OR FOR SHORT JUST Wrksheets("sheet name here").unprotect("password here")

    IF you then want to reprotect the sheet after the macro makes the changes, you can add this line:

    Worksheets("sheet name here").protect password:="password here" (there are other parameters you can set other than just a password...you can look at the help menu for this method to learn more).

    General Structure for approach 2:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by GeneralDisarray; 05-08-2012 at 01:54 PM. Reason: forgot to upload attachment

  7. #7
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    Thankyou very much for your time and assistance GeneralDisarray, very informative and useful info.
    Just one more thing though. sheet 2 is protected now and I don't know the password......tried secret2 or did I misunderstand something?

  8. #8
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: run time error 1004, cell or chart is protected.

    hmm...i don't know exactly what you ran, maybe you can post the workbook? what i meant to indicate was the password should go in the code.

  9. #9
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    @ General Disarray...........the file is in your reply above (Steve Unprotected(2).

    I understand how to do Method 1 and so this is how I have done the attached file, however in this attached one the sheets are not protected. The orange cells through-out the workbook are the ones that should be allowed for user entry.
    When I then protect the Cost Summary page I then get runtime errors on first sheet (Main Data) when I click in the orange fields that I need to enter data into. The fields on Main data have to be filled in as this is what denotes what values come from elsewhere in the document and popuplate values on the Costings sheet.

    If you password protect please use 1234 as password

    Thanks for your assistance and understanding
    Last edited by ndtsteve; 05-09-2012 at 09:36 AM. Reason: Added comment about passwrd

  10. #10
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    Still ongoing and haven't found a way around my problem

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: run time error 1004, cell or chart is protected.

    ok, not sure if this is what you are after or not (attached).
    Attached Files Attached Files

  12. #12
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    @ GeneralDisarray,
    Thing I have noted is that as soon as I protect the Cost Summary sheet then I get errors pop up when I try enter data on the Main Data sheet. I intend to protect all the sheets in the workbook so that people don't mess up coding and formulas etc.

  13. #13
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: run time error 1004, cell or chart is protected.

    Are you using the one i attached on my last post or some other sheet? I don't have that error happening on what i've just returned.

    The only thing you might be missing is, you need to include the uprotect line in your macro (with the proper password "1234") OR you just need to "allow users to edit" any cell being changed by the macro. BUT in what i've just attached it looks like you will need to unprotect/protect the sheet because you have not allowed the users to edit cell p13.

    Proper unprotect/protect lines look something like: (This was the macro included in the main Data code module on the last attachment i returned to you).
    Please Login or Register  to view this content.

    ---------
    NOTE: i am not having the problem you describe on the sheet i just attached on my last post.

  14. #14
    Forum Contributor ndtsteve's Avatar
    Join Date
    05-01-2012
    Location
    Guildford, Surrey, England
    MS-Off Ver
    365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
    Posts
    110

    Re: run time error 1004, cell or chart is protected.

    @ General...............thanks for your time and efforts on my behalf. I will look into this tomorrow as kids are home from school now and things start to get hectic with their various clubs etc.
    I assume I can just copy the same coding relevant to the password protection stuff staright into the code for the other sheets?

    Again, thanks a lot...........Steve

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1