+ Reply to Thread
Results 1 to 4 of 4

Using VBA to protect sheet, but to allow marco to function

  1. #1
    Registered User
    Join Date
    09-06-2021
    Location
    Northern Ireland
    MS-Off Ver
    365
    Posts
    20

    Using VBA to protect sheet, but to allow marco to function

    Hi all,

    I am running into problems trying to get the correct VBA code to protect table in my document, hiding the formula and abilty to edit whilst also making sure that macros included to add and remove data are still working.

    So far if I protect my sheet I am unable to get macros to work. It displays error: Run-ime error '1004': Table features aren't available because the sheet is protected. When I go to debug .ListColumns(3).Delete is highlighted in yellow for this macro to reset table data.

    Sub ResetTable()
    Dim i As Long
    With ThisWorkbook.Sheets("Table")
    .Range("C6") = "England"
    .Range("C8") = "Please Select"
    With .ListObjects(1)
    .Range(2, 2) = ""
    For i = 3 To .DataBodyRange.Columns.Count
    .ListColumns(3).Delete
    Next i
    End With
    End With
    End Sub

    Any help is greatly appreciated

    Thank you

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Using VBA to protect sheet, but to allow marco to function

    Try some thing like this
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-06-2021
    Location
    Northern Ireland
    MS-Off Ver
    365
    Posts
    20

    Re: Using VBA to protect sheet, but to allow marco to function

    Hi Mohadin,

    Thanks for this it is coming up with the same error code, when I add this.

    Can it be protected without using a password?

  4. #4
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Using VBA to protect sheet, but to allow marco to function

    Can it be protected without using a password?
    Yes
    Please Login or Register  to view this content.

+ 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. Protect the Spreadsheet from being modified and still have the sheet function
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-19-2014, 06:24 AM
  2. Edit existing marco to unlock protect sheet, remove set criteria and re protect sheet
    By summer2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2013, 09:29 AM
  3. Marco to Lock/Unlock and Protect/Unprotect Multiple Excel Workbooks
    By Jgonza25 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2013, 03:29 PM
  4. Protect sheet function is not working
    By ebe in forum Excel General
    Replies: 3
    Last Post: 08-11-2010, 12:04 PM
  5. [SOLVED] Am I able to protect my work sheet and keep my grouping function?
    By Djana in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-30-2006, 08:50 PM
  6. How do use list with protect sheet function?
    By quantn in forum Excel General
    Replies: 0
    Last Post: 02-18-2006, 02:00 PM
  7. [SOLVED] How do I unprotect/with password to run marco and protect
    By J_Will in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2006, 06:00 PM

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