Is there any way to lock the excel cell if it has value and unlock it if it has no value contained?
e.g. if Persone updates the excel-sheet and sends it to another person, the second person only allows the update blank cells.
CodePudding user response:
LEt's say your data is they grey zone in the image below:
You want to lock all grey cells with values and keep unlocked the empty white cells. Manually, you can do it like this:
- Select all grey zone (your whole dataset)
- Right click--> Format Cells
- A dialog box appears. Go to tab protect and make sure checkbox locked is checked!
- Close dialog box
- Select again all grey zone (your whole dataset)
- In the upper option ribbon, go to tab Start and search for option Find & Select and then
- Select option
- Now repeat steps 2 to 4 but selection option unlocked in step 3
Now your empty cells are unlocked and nonempty cells are locked. Make sure you
Every time a cell is changed, if the cell ends up with a value in it, then it will lock that cell.
Private Sub Worksheet_Change(ByVal Target As Range) If Not Target.Value = "" Then ActiveSheet.Unprotect Target.Locked = True ActiveSheet.Protect End If End Sub
It does mean you can enter values into a cell exactly once, and then you have to unprotect the sheet to delete the values entered. not exactly the solution you are after I fear...
- Select option