Lock Cells

jordanstuart

New Member
Joined
Jul 27, 2017
Messages
3
I'm trying to sort data in a range of data, but i'm need to lock some of the cells within to ensure that the formulas in the cells aren't changed. Here is an example of the data that I need to sort. Is there a formula or VBA code to lock these cells, but still allow them to be sorted based on their score?

PersonRegionHCOOOUP OOOSSAHCDPHISMs%PPDSubDPHISMGoalsSCORE
AshleyFlorida221547.25318.2860.4793.21%4.90%24.6427.40200.0029.40
AlexColorado251963.81821.1969.2292.96%3.82%22.4224.88200.5027.38
MikeTexas232147.252120.1670.9293.92%3.62%21.9124.32200.5026.82
DanTexas211962.751516.8469.5296.78%3.38%20.1122.38210.7526.13

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
simple version of it. I am sure someone could put together a more elaborate version.

highlight your selected area and then run -

Code:
Sub ProtectCells()
    Dim c As Range
    
        For Each c In Selection
            Selection.Locked = True
            Selection.FormulaHidden = True
        Next c
            With ActiveSheet
                .Protect Password:="YourPassword", AllowFiltering:=True
                .EnableSelection = xlUnlockedCells
            End With
End Sub
 
Last edited:
Upvote 0
We are trying to use this, but it is locking everything so we are unable to sort this. Are there any other suggestions you have for fixing this?
 
Upvote 0
Try adding this
Code:
    Cells.Locked = False
before the For Each
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,148
Members
449,098
Latest member
Doanvanhieu

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