locking specific cells in sheet (Northants)

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
HI Can you help me please i have the code below, but it doesnt seem to work, i think i am putting the code in the wrong place i added this to a new module but it doesnt work, i only want to lock cells in sheets(Northants) and the cells i want to lock are B8, B9, B10, B11, F8 and F9, can you help and advixse me please, thanks in advance.

Code:
Sub LockCellsWithFormulas()
With ActiveSheet
   .Unprotect
   .Cells.Locked = False
   .Cells.SpecialCells(xlCellTypeFormulas).Locked = True
   .Protect AllowDeletingRows:=True
End With
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi me again, i didnt explain sorry what was in thopse specific cells that i want to lock, i have in there codes for Vlookup, SUM, COUNTIF etc, which i do not want people clicking on to mess up the code, if you can help please :), thank you again, i am still fairly new to all of this.
 
Upvote 0
Hi sorry to bother you again, just wondering if you had any ideas at all with regards to my query? if you need any more information please let me know.
 
Upvote 0
Change Active sheet to the name of the sheet you want to protect.
 
Upvote 0
Hi thx for that i have changed the code to....for example?
Code:
With Sheets (Northants)

And where do i put this code do i put it in sheet 1 (Northants)? as i have tried this but unfortunately it still doesnt work its not locked any cells in Northants sheet :(
 
Last edited:
Upvote 0
You can leave the code where it is, but you're missing the " marks either side of the sheet name
 
Upvote 0
Hi thx for that, i have tried that and it still doesnt work :( i have entered the code into 'Sheet1 (Northants). is this the correct place to put it? or do i put it in a module or ThisWorkbook?
 
Upvote 0
It needs to go in a regular module
 
Upvote 0
hi this does work now but i found out after looking on internet that i needed to protect the spreadsheet, which i did but i now get a run-time error 1004 for the code
Code:
.Cells(emptyRow, 1).Value = TextBox1.Value
any ideas please?
 
Upvote 0
That code has nothing to do with the code in your op, & therefore very difficult to tell.
Did you unprotect the sheet?
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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