marreco
12-31-2011, 03:37 AM
Hi....
Personally I have 3 users that use a single worksheet.
The users User1 and User2 feeds the sheet named "Master"
User3 analyzes information but if there is something wrong he alone will have the Permissions to change the data in the spreadsheet "Master".
So ...
The code below works perfectly, but I would add an input box to allow only user3 can change the worksheet data "Master".
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewValue As Variant, OldValue As Variant
If Target.Count > 1 Then Exit Sub
'Say you want to work with the range A1:F100
If Not Intersect(Target, Range("A1:F10")) Is Nothing Then
NewValue = Target.Value
Application.EnableEvents = False
Application.Undo
OldValue = Target.Value
If OldValue <> "" Then
MsgBox "Você não pode alterar o conteudo da celula.", 16, "Células Bloqueadas"
Target.Value = OldValue
Else
Target.Value = NewValue
End If
Application.EnableEvents = True
End If
End Sub
cross-posting
http://www.excelforum.com/excel-programming/807559-cells-blocked-with-permission-to-change.html
Can anyone help me?
Thank you!
Personally I have 3 users that use a single worksheet.
The users User1 and User2 feeds the sheet named "Master"
User3 analyzes information but if there is something wrong he alone will have the Permissions to change the data in the spreadsheet "Master".
So ...
The code below works perfectly, but I would add an input box to allow only user3 can change the worksheet data "Master".
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewValue As Variant, OldValue As Variant
If Target.Count > 1 Then Exit Sub
'Say you want to work with the range A1:F100
If Not Intersect(Target, Range("A1:F10")) Is Nothing Then
NewValue = Target.Value
Application.EnableEvents = False
Application.Undo
OldValue = Target.Value
If OldValue <> "" Then
MsgBox "Você não pode alterar o conteudo da celula.", 16, "Células Bloqueadas"
Target.Value = OldValue
Else
Target.Value = NewValue
End If
Application.EnableEvents = True
End If
End Sub
cross-posting
http://www.excelforum.com/excel-programming/807559-cells-blocked-with-permission-to-change.html
Can anyone help me?
Thank you!