The function unprotects the sheet, determines if the selected cell(s)
require locking of BCD and then protects the sheet, so you only need to
protect the sheet if you unprotect it manually. Even in that event, the
first time you make a change it column A, it will protect it automatically.
You might however need to prime the pump (so to speak) by causing the cells
in column A to be changed to trigger the function. To do this, copy column
A and paste it over column A (actually you might just want to copy and paste
the part with values as it could take a while to do the whole column). This
will cause the function to relock the cells in BCD as required.
To unprotect cells, unprotect the sheet, select the cells you wish to
unlock, then reprotect the sheet. However, the function may relock the cell
if it's in B C or D as changes are made. As written there is no way around
this.
The target cell is likely locked. You can unlock it as above but again the
function may relock it.
If the area you need the function to cover includes all of ABCD then you can
just unlock all cells on the sheet, then prime the pump as above. You'll
then need to lock any additional cells you need locked.
If the area you need the function does not include all of ABDC, you can
adjust the fuction by replace the text "A:A" with the range of column A to
monitor (e.g. "A2:A25") in both places it appears in the code. Then unlock
all cells, prime the pump and relock other cells as needed.
A more general solution that occurs to me would be to use a second hidden
sheet as a locking map. You could then place flags on the map to indicate
whether matching cells on the first sheet should be locked. These flags
could be generated by formulas yielding condional locking. The check to
lock a cell would be made as it becomes selected. However, this wouldn't be
efficient for large selections (whole columns say), and I'm not sure if you
really need a solution this general or if there isn't an easier or better
way to accomplish much the same thing.
HTH