nhkhurum said:
I have lot of data in sheet 1 (for whole years) I want to lock cell from
A~F when in cell G i give some criteria Like Posted. Whole the sheet
remain unprotected.
To lock all of the cells in A:F in the current row based on the contents of G
[current row], it's like this:
Sub lockWhenCriteriaMet1()
Dim cell As Range
For Each cell In Range("G:G")
If cell.Value = criteria Then
Range("A" & cell.Row & ":F" & cell.Row).Locked = True
End If
Next
End Sub
If the cells are locked individually, based on G, then it's more like this:
Sub lockWhenCriteriaMet2()
Dim cell As Range
For Each cell In Range("G:G")
Select Case cell.Value
Case criteria_A
Cells(cell.Row, 1).Locked = True
Case criteria_B
Cells(cell.Row, 2).Locked = True
'etc...
End Select
Next
End Sub