How to disable changes in a cell using vba? How to disable changes in a cell using vba? vba vba

How to disable changes in a cell using vba?


If you want to protect only Range B1:B10 then you need to run this sub only once:

Sub ProtectCellsInB()    Worksheets("Sheet1").Cells.Locked = False    Worksheets("Sheet1").Range("B1:b10").Locked = True    Worksheets("Sheet1").Protect Password:="pass", UserInterfaceOnly:=TrueEnd Sub

I made a modification- I added a password to protection which you can delete.

If you are not sure how to run it once then you could add the whole internal code at the end of your Private Sub Worksheet_Change(ByVal Target As Excel.Range)