I need to be able to do this in a module, not a sheet module as I am planning to press a button to apply this to the cells manually.Is it possible to select a used cell ie one that is not blank and ingore all others in a cell range?
For example, if B11 is not blank, then remove the cell protection across the row, otherwise do nothing.
Many thanks.
I have tried this, but the cells in column B that are blank are not protected, which I need them to be.Maybe like this
Code:Sub test() ActiveSheet.Unprotect Password:="password" With Columns("B").SpecialCells(xlCellTypeConstants) .EntireRow.Cells.Locked = False End With ActiveSheet.Protect Password:="password" End Sub
Sub test2()
ActiveSheet.Unprotect Password:="password"
With Columns("B").SpecialCells(xlCellTypeConstants)
.EntireRow.Cells.Locked = False
End With
With Columns("B").SpecialCells(xlCellTypeBlanks)
.EntireRow.Cells.Locked = True
End With
ActiveSheet.Protect Password:="password"
End Sub
Many thanks for this, but its not quite what I am looking for.They must have been unlocked to start with. Try
Code:Sub test2() ActiveSheet.Unprotect Password:="password" With Columns("B").SpecialCells(xlCellTypeConstants) .EntireRow.Cells.Locked = False End With With Columns("B").SpecialCells(xlCellTypeBlanks) .EntireRow.Cells.Locked = True End With ActiveSheet.Protect Password:="password" End Sub