D
daved37
Hello,
I'm trying to use FOR - NEXT to cycle through the Range B:B or even
better go to the last row (which I don't know how to do successfully -
it always stops short a few rows). I would like to find each cell that
has an "X" and then lock that row or if no "X" leave it unlock.
I have the entire worksheet unlock - so when this runs the only locked
rows are the ones with an "X" in Column B.
Here is my code so far, it locks cell A1 and that's it:
Sub LockCells()
Dim test1 As Range
Set test1 = Range("B2, B150")
For Each test1 In Selection
If test1 = "" Then
ActiveCell.Locked = False
ActiveCell.FormulaHidden = False
Else
ActiveCell.Locked = True
ActiveCell.FormulaHidden = True
End If
Next
End Sub
Many Thanks!!
Dave
I'm trying to use FOR - NEXT to cycle through the Range B:B or even
better go to the last row (which I don't know how to do successfully -
it always stops short a few rows). I would like to find each cell that
has an "X" and then lock that row or if no "X" leave it unlock.
I have the entire worksheet unlock - so when this runs the only locked
rows are the ones with an "X" in Column B.
Here is my code so far, it locks cell A1 and that's it:
Sub LockCells()
Dim test1 As Range
Set test1 = Range("B2, B150")
For Each test1 In Selection
If test1 = "" Then
ActiveCell.Locked = False
ActiveCell.FormulaHidden = False
Else
ActiveCell.Locked = True
ActiveCell.FormulaHidden = True
End If
Next
End Sub
Many Thanks!!
Dave