How to make read-only cells in spreadsheets?

I populate the table with database values. The cells that I fill with data, I want them to be read-only to users. How can i do this?

+5
source share
5 answers

Depends on how you want to select a range. This is just one cell. If you go back to J1 and change the value, you should receive a request.

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 will need to unlock the cells that you want to change.

+5
source

, - , , UserInterfaceOnly, .

ActiveSheet.ProtectUser InterfaceOnly:=True

, , , .., , .

+4

. SelectionChange...:

   Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      If Not Intersect(Selection, Range("A24:A50")) Is Nothing Then
        Range("B1").Select
      End If
    End Sub
+1

.

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 
    If Not Intersect(Target, Range("H1:H10")) Is Nothing Then 
        Target.Offset(0, 1).Select 
        MsgBox "you may not enter that cell" 
    End If 
End Sub

To protect H1:H10. When the user wants to change the cell within H1:H10, a warning message indicates that the cell cannot be changed, and the next cell in the next column ( I) will be selected.

0
source

In excel, you can go to the "Protection" menu and specify which cells will require a password change. You can also specify multiple ranges.

Hope this is what you were looking for.

0
source

All Articles