+ Reply to Thread
Results 1 to 13 of 13

VBA script not running with blocked cells (not the ones the vba script is using)

  1. #1
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Question VBA script not running with blocked cells (not the ones the vba script is using)

    Hi,

    so I'm running a vba script which should change the color of a cell after the user has been modifying the sheet.
    The cells the script is coloring in is not protected, but other cells in the same row. (7+)

    Without protection the script is running fine, with I'm running into an error (request to debug).
    I have no clue why.

    Please Login or Register  to view this content.
    I can and will provide any necessary data anybody needs to solve this puzzle.
    Hope somebody can help me,
    Edward

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Unprotect the sheet at the beginning of your code, then protect it again at the end of the code.

  3. #3
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Quote Originally Posted by davesexcel View Post
    Unprotect the sheet at the beginning of your code, then protect it again at the end of the code.
    Changed it to
    Please Login or Register  to view this content.
    , but still getting the same error.

    Attachment 814919

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Where are you unprotecting the sheet?

    Search for "excel vba unprotect sheet"

  5. #5
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Quote Originally Posted by davesexcel View Post
    Where are you unprotecting the sheet?

    Search for "excel vba unprotect sheet"
    I thought it was:
    Please Login or Register  to view this content.
    But after using your searchterm I found this:
    Please Login or Register  to view this content.
    Do I need only the 2nd one, or both?

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Just the one to unprotect the sheet

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Did you select the option to allow formatting cells when protecting the sheet?
    Rory

  8. #8
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Quote Originally Posted by rorya View Post
    Did you select the option to allow formatting cells when protecting the sheet?
    How do I do that? I'm quite a noob with vba and just clobbering this together.

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Did you protect the sheet in code originally? If not, just check that option when protecting the sheet in the UI. If you did do it in code, it's like this:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Quote Originally Posted by rorya View Post
    Did you protect the sheet in code originally? If not, just check that option when protecting the sheet in the UI. If you did do it in code, it's like this:

    Please Login or Register  to view this content.
    I did it using the GUI.
    Might that be the problem? Problem is, I need only to protect some cells, so nobody is overwriting the formulas.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    When you protect the sheet in the UI, one of the options you can set is to allow formatting cells. Then your code should just work as is.

  12. #12
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Quote Originally Posted by rorya View Post
    When you protect the sheet in the UI, one of the options you can set is to allow formatting cells. Then your code should just work as is.
    And that was the fast solution
    Thank you very much.

  13. #13
    Registered User
    Join Date
    03-16-2021
    Location
    Germany
    MS-Off Ver
    O365
    Posts
    26

    Re: VBA script not running with blocked cells (not the ones the vba script is using)

    Quote Originally Posted by davesexcel View Post
    Just the one to unprotect the sheet
    Will keep that in mind.
    How do I protect the VBA code if the password is in there in plain text?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. script to run the macro from Vb script with out opening the excel file
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2021, 03:33 AM
  2. Need A Fast Script To Copy 80000 Cells But My Current Script Is Too Slow
    By Genus Max in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-20-2019, 09:54 AM
  3. calling the vb script from the shell script(unix platform)
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 06:21 AM
  4. Integrating Mainframe emulator script with excel's vba script
    By Himanshu Mishra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 10:30 AM
  5. Create VBA script to short, dedicated button in excel for script?
    By realized in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2009, 11:54 PM
  6. Script that edits the text printed on the button that runs the script
    By petalred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2008, 02:41 PM

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