+ Reply to Thread
Results 1 to 2 of 2

How to Stop the Macro from Disabling the Sort and Filter Functions?

Hybrid View

bssol How to Stop the Macro from... 09-07-2013, 06:32 AM
fredlo2010 Re: How to Stop the Macro... 09-07-2013, 08:45 AM
  1. #1
    Registered User
    Join Date
    01-11-2013
    Location
    dammam
    MS-Off Ver
    Excel 2013
    Posts
    31

    Talking How to Stop the Macro from Disabling the Sort and Filter Functions?

    I have sheet with a macro that unprotect then protect the sheet everytime it runs. Even if sort, filter, and selecting locked cells is enabled, once
    you run the macro it will automatically disable these functions.


    See attached sheet Vendor Registration Tracking.simple2.xlsm

    Please help!

    Code:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
        
    Sheets("Vendor Tracking").Unprotect Password:="123"
      With Target
          If .Count > 1 Then Exit Sub
          If Not Intersect(Range("E6001:E10000"), Target) Is Nothing Then
              Application.EnableEvents = False
              With .Offset(0, 1)
                  .NumberFormat = "dd/mmm/yyyy"
                  .Value = Date
              End With
              Application.EnableEvents = True
          End If
      End With
      Sheets("Vendor Tracking").Protect Password:="123"
    End Sub

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: How to Stop the Macro from Disabling the Sort and Filter Functions?

    Hi bssol,

    See if this helps

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
        
    Sheets("Vendor Tracking").Unprotect Password:="123"
      With Target
          If .Count > 1 Then Exit Sub
          If Not Intersect(Range("E6001:E10000"), Target) Is Nothing Then
              Application.EnableEvents = False
              With .Offset(0, 1)
                  .NumberFormat = "dd/mmm/yyyy"
                  .Value = Date
              End With
              Application.EnableEvents = True
          End If
      End With
      
      'set false or true the features you want enable or disabled
      Sheets("Vendor Tracking").Protect Password:="123", _
                                        DrawingObjects:=False, _
                                        Contents:=True, _
                                        Scenarios:=False, _
                                        AllowFormattingCells:=True, _
                                        AllowFormattingColumns:=True, _
                                        AllowFormattingRows:=True, _
                                        AllowInsertingColumns:=True, _
                                        AllowInsertingRows:=True, _
                                        AllowInsertingHyperlinks:=True, _
                                        AllowDeletingColumns:=True, _
                                        AllowDeletingRows:=True, _
                                        AllowSorting:=True, _
                                        AllowFiltering:=True, _
                                        AllowUsingPivotTables:=True
    End Sub
    Thanks

+ 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. Disabling the Advanced filter function
    By ngk08 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-03-2016, 06:15 PM
  2. [SOLVED] Macro to Sort/Filter
    By anassboum in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2012, 11:03 AM
  3. If no items in column sort - how to stop macro copying all entries
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2008, 12:50 PM
  4. Disabling Excel's Sort menu
    By bettatronic in forum Excel General
    Replies: 1
    Last Post: 04-02-2007, 02:27 PM
  5. Sort and filter macro
    By KH_GS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2006, 04:15 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