+ Reply to Thread
Results 1 to 5 of 5

Delete special cells & protected workbook

  1. #1
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Delete special cells & protected workbook

    Hi,

    I have a code which deletes all contents of cell in range except formulas, from sheet 2 to 13. Code works, but I have included toggle button on each sheet to lock/unlock sheets.

    If I lock sheets, code doesn't erase cells as needed.

    I have figured out code that works for me, but looks like It's not performing quite correct. Although code executes quite quick...

    This is my current code :
    Please Login or Register  to view this content.
    Just need to ask, how could I rearrange this code to work in proper order ?

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Delete special cells & protected workbook

    Hi, Lukael,

    with your code you leave all the sheets unprotected - is that wanted? Do you have Events behind the Sheets/Workbook that lock the cells?

    Please Login or Register  to view this content.
    I would prefer not to work with the index of the worksheets which may be different if any user drags sheets around and may lead to unwanted results.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Delete special cells & protected workbook

    Hi Hahobe,

    leaving sheets protected or unprotected after clearing is not relevant, user changes that by himself. I should just unprotect them If they are protected, so that cells are really cleared on new sheets, otherwise they are not.

    Your code works as mine with difference of protecting them...

    Problem I want to solve is that when code is generated, you can see for first three new sheets that special cells don't get clear but after that every new sheet is cleared. In the end, when I check sheets, they are all cleared, so both codes work.

    I'm just assuming that something is wrong with code...

    Do you have Events behind the Sheets/Workbook that lock the cells?
    If you meant this - I have code for toggle button to lock/unlock cells behind Sheet 1. This sheet is then being copied 12 times, so that code is then under all sheets.

    Code is :

    Please Login or Register  to view this content.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Delete special cells & protected workbook

    Hi, Lukael,

    the more I read your last post the less I get what you want, what the code does or does not - Iīm afraid I canīt answer what you ask for simply because I donīt understand what you realy want. Iīm somehow lost at this.

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Delete special cells & protected workbook

    Hi Hahobe,

    I know I was unclear. There was a lot of mistakes done in my code, so I had to change a lot of things, and finally got It working. Biggest problem was with my Toggle button,not in code that was provided. I just had to .Unprotect and .Protect again everytime I cleared or hided something in VBA, and figured that this had to be done in several places.

    In short, this is part of the code that now works for special cells :


    Please Login or Register  to view this content.
    Beside that, I had to create a new Open_Workbook event and added more code for doing something else. Now It works, as It should !

    Thanks for help, sorry for being unclear

+ 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. Replies: 0
    Last Post: 03-20-2014, 11:51 AM
  2. Want to delete all non-protected cells in a worksheet
    By BillDoor in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-14-2013, 11:31 AM
  3. Delete rows in a protected sheet with protected cells
    By Maranwe in forum Excel General
    Replies: 7
    Last Post: 10-31-2011, 08:12 AM
  4. Special Cells Delete Shift up not consistent
    By BHudPE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2011, 11:42 AM
  5. [SOLVED] Macro to delete row with protected cells
    By Turboj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2006, 12:45 AM

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