I'm populating a spreadsheet with Database values. The cells that I fill data with, I want them to be read-only to the users. How can I do this?
Select the column you want to protect, right Click->Format Cells->Protection, select the "Locked" check box. Review tab->Protect Sheet, select the "Protect worksheet and contents of locked cells" check box and protect the sheet using a password.
Select the cells you want to lock. On the Home tab, in the Alignment group, click the small arrow to open the Format Cells popup window. On the Protection tab, select the Locked check box, and then click OK to close the popup.
Depends on how you want to select the range. This is just one cell. If you go back to J1 and change the value, you should get prompted.
Private Sub Worksheet_Change(ByVal Target As Range)
Range("J1").Select
Selection.Locked = True
ActiveSheet.Protect Contents:=True
Range("K1").Select
End Sub
Cells are not locked until the worksheet is protected. By default all cells are set to Locked, so you'll have to unlock cells you want users to be able to change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With