Sorting protected and locked cells

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
795
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Is it possible to even do this? everywhere i search it seems to be the same dilemma. Trying to just execute the below code, when all my cells are set to locked. and getting the below error message.
VBA Code:
Sub Button1_Click()

With ActiveSheet
    .Unprotect
    .Range("8:8").AutoFilter
    .Protect , AllowFiltering:=True, AllowSorting:=True, DrawingObjects:=True, Contents:=True
End With

End Sub

VBA TESTING.xlsm
ABCDEFGHIJKL
1
2
3
4
5
6
7
8Field 1Field 2Field 3Field 4Field 5Field 6
91ABCDE
102ABCDE
113ABCDE
124ABCDE
135ABCDE
146ABCDE
157ABCDE
168ABCDE
179ABCDE
1810ABCDE
1911ABCDE
2012ABCDE
2113ABCDE
2214ABCDE
2315ABCDE
2416ABCDE
2517ABCDE
2618ABCDE
2719ABCDE
Sheet2


1603376555045.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You cannot sort locked cells on a protected sheet.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,877
Messages
6,127,494
Members
449,385
Latest member
KMGLarson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top