+ Reply to Thread
Results 1 to 5 of 5

Disable editing in file

  1. #1
    Forum Contributor
    Join Date
    11-05-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    181

    Disable editing in file

    Hi All,

    I'm creating a report where the end user will not be allowed to delete rows/columns or change values inside the cells.

    Each variation of protecting the worksheet I've tried has resulted in the disabling of sorting. I need for this to be a capability (sorting and filtering will be necessary for this report). Is there a macro I can use to give users the capability to filter and sort while preventing them from deleting/adding rows and columns and editing cell values?

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,007

    Re: Disable editing in file

    The last two options when protecting a worksheet are to allow users to sort and to use autofilters, so select those options when protecting the sheet.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    11-05-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    181

    Re: Disable editing in file

    When I check to allow users to sort and use autofilter I still am not able to sort data. Message pops up: "The cell or chart you're trying to change is on a protected sheet"

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,007

    Re: Disable editing in file

    For filtering, the filter needs to be applied before protection. For sorting, unfortunately, the cells must be unlocked.

    You could also use the worksheet change event to undo any changes.

    1) Copy this code.
    2) Right-Click the sheet tab of interest.
    3) Select "View Code"
    4) Paste the code into the window that appears.
    5) Save the file as a macro-enabled .xlsm file.
    6) Make changes as needed


    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Application.Undo
    Application.EnableEvents = True
    End Sub

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,909

    Re: Disable editing in file

    When a worksheet is protected all actions to modify manually are blocked.
    However when you have vba code that makes the changes you can add a parameter to the code protecting the worksheet that will allow changes made by a macro and not by the user.

    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

+ 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: 09-06-2013, 05:31 AM
  2. How to disable direct cell editing by typing, but allow formulas?
    By matkiros in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2012, 07:04 AM
  3. disable cell content editing, but allow row/column removal
    By Heliux in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-24-2009, 11:18 AM
  4. Disable Editing a Cell Without Protecting the Worksheet
    By akabraha in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-02-2008, 06:46 PM
  5. Disable Editing tool bars
    By Mike Rogers in forum Excel General
    Replies: 8
    Last Post: 12-09-2005, 05:25 PM
  6. [SOLVED] Disable CommandBar buttons while editing the cell
    By Vinit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-16-2005, 03:05 AM
  7. [SOLVED] disable cells editing
    By Sam in forum Excel General
    Replies: 6
    Last Post: 04-24-2005, 01:06 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