Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cell As Range
Set rng = Intersect(Target, [D:D])
If rng Is Nothing Then Exit Sub
For Each cell In rng
If cell = "" Then
cell.Locked = False
Else
cell.Locked = True
End If
Next
End Sub