+ Reply to Thread
Results 1 to 13 of 13

Delete contents of protected cells using VBA

  1. #1
    Registered User
    Join Date
    02-08-2017
    Location
    Egypt
    MS-Off Ver
    2007
    Posts
    11

    Delete contents of protected cells using VBA

    I've created a user form template where the user will input in some fields and click a button "add to database" then the input will be moved to another worksheet and all the content in the "input" sheet will be cleared

    the problem is that when i try to lock any cell in the input sheet the clear content VBA will not work

    is there a way to run a clear content VBA on a locked cell at the end i need to lock cell D11 and cell D13 in the "Input" sheet
    Please Login or Register  to view this content.
    Last edited by FDibbins; 02-09-2017 at 03:08 AM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Delete contents of protected cells using VBA

    Have you tried unlocking and then re-locking the cells in the VBA?
    Martin

  3. #3
    Registered User
    Join Date
    02-08-2017
    Location
    Egypt
    MS-Off Ver
    2007
    Posts
    11

    Re: Delete contents of protected cells using VBA

    I tried to lock the cells by another VBA code but also the clear content vba is not working

    I'm new to VBA so if locking and re locking will solve the problem, please advice how to do that , it will be a new macro or just modify the existing one ?

    If it is a modefication , plesse advice what and where should i add to the above code

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Delete contents of protected cells using VBA

    May you upload a sample workbook?
    Teach me Excel VBA

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Delete contents of protected cells using VBA

    And specify which cells you want to lock/unlock

  6. #6
    Registered User
    Join Date
    02-08-2017
    Location
    Egypt
    MS-Off Ver
    2007
    Posts
    11

    Re: Delete contents of protected cells using VBA

    I've uploaded the sheet

    Current behavior:
    When i input the data in "Input" sheet
    it is getting fetched in the "Consolidated sheet" and all the content will be cleared from the "Input" sheet to be ready for inputting another data.

    Required behavior:
    I just want the macro to work as it is while locking the following fields against any user editing

    1 - (D11)" & (D13) in sheet "Input"
    2 - "Consolidation" sheet, so that user can only view the data in this sheet without the ability to edit

    Thank you so much
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Delete contents of protected cells using VBA

    See if the attached helps you.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-08-2017
    Location
    Egypt
    MS-Off Ver
    2007
    Posts
    11

    Re: Delete contents of protected cells using VBA

    This is extremely helpful
    Really thank you so so much Imran

    but is it possible to do the first part also (Point no. 1)
    which is also locking (D11)" & (D13) in sheet "Input" ??

  9. #9
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Delete contents of protected cells using VBA

    Quote Originally Posted by Ahmed519 View Post
    This is extremely helpful
    Really thank you so so much Imran

    but is it possible to do the first part also (Point no. 1)
    which is also locking (D11)" & (D13) in sheet "Input" ??
    In sheets Input I have only locked D11 and D13 while the other sheets are fully locked for editing except the information transferred from your form.

    Do you want to lock all cells in sheet input except D5,D7 and D9?

  10. #10
    Registered User
    Join Date
    02-08-2017
    Location
    Egypt
    MS-Off Ver
    2007
    Posts
    11

    Re: Delete contents of protected cells using VBA

    Yes please, I want to also lock all cells in sheet "input" except D5,D7,D9 so users can only edit those three cells only in the whole workbook. Really thank you so much for your great help

  11. #11
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Delete contents of protected cells using VBA

    Quote Originally Posted by Ahmed519 View Post
    Yes please, I want to also lock all cells in sheet "input" except D5,D7,D9 so users can only edit those three cells only in the whole workbook. Really thank you so much for your great help

    I have done it for you if you need to un protect the sheets for further formatting the password is 123.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    02-08-2017
    Location
    Egypt
    MS-Off Ver
    2007
    Posts
    11

    Re: Delete contents of protected cells using VBA

    I'm really appreciating your help
    Thank you so so much

  13. #13
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Delete contents of protected cells using VBA

    You are welcome!

+ 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. Need to delete rows in sheet with protected cells
    By Timmy2tone in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2014, 03:41 PM
  2. Delete only some of a cells contents
    By Dendrinos2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-11-2014, 06:16 AM
  3. [SOLVED] Delete special cells & protected workbook
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-30-2014, 10:11 AM
  4. 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
  5. 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
  6. Add/Delete Rows with Protected Cells
    By NoiCe in forum Excel General
    Replies: 1
    Last Post: 10-22-2009, 02:59 AM
  7. [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

Tags for this Thread

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