Lock Row (A~F) based on criteria in g

N

nhkhurum

I have lot of data in sheet 1 (for whole years) I want to lock cell fro
A~F when in cell G i give some criteria Like Posted. Whole the shee
remain unprotected.

Regards

Noo
 
A

Auric__

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top