-
Cells blocked with permission to change
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".
[VBA]
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[/VBA]
cross-posting
http://www.excelforum.com/excel-prog...to-change.html
Can anyone help me?
Thank you!
-
Hello folks, I'd love your help.
I know we have teachers excel in this forum, please help me ..... thanks!
-
Hi. Try this:
replace these lines
[vba] If OldValue <> "" Then
MsgBox "Você não pode alterar o conteudo da celula.", 16, "Células Bloqueadas"
Target.Value = OldValue
Else
Target.Value = NewValue
[/vba]
with these ones
[vba] If OldValue = "" Then
Target.Value = NewValue
ElseIf InputBox("enter password") = "pwd" Then
Target.Value = NewValue
Else: MsgBox "Você não pode alterar o conteudo da celula.", 16, "Células Bloqueadas"
Target.Value = OldValue
[/vba]
don't forget to protect your VBA project to avoid that one could see the 'pwd'
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules