protecting cells by password

H

Hardeep_kanwar

you areHi! All Expert

Is it possible to protect five or six cell with a password. I mean to say if
somebody edit or type in these cell excel ask for a password.

I dont want excel will show the warning ( The cell or chart you are trying
to change is protected and therefor read- only).

I want to show only PASSWORD Option.

Any help will be Appriciate

Hope to hear your soon

Thanks in Advance

Hardeep kanwar
 
O

Otto Moehrbach

You must use VBA for this. Copy the following macro and place it in the
sheet module of your sheet. To access that module, right-click on the sheet
tab and select View Code. "X" out of the module to return to your sheet. I
assumed that the range of cells was named "TheRng" and the password is
"ThePassword". Change these in the code as needed. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TheEntry As Variant
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("TheRng")) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
TheEntry = Target.Value
Application.Undo
If InputBox("Please enter the password.") = "ThePassword" Then
Target.Value = TheEntry
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
 
H

Hardeep_kanwar

Thanks Sir
It works Great

hardeep kanwar

Otto Moehrbach said:
You must use VBA for this. Copy the following macro and place it in the
sheet module of your sheet. To access that module, right-click on the sheet
tab and select View Code. "X" out of the module to return to your sheet. I
assumed that the range of cells was named "TheRng" and the password is
"ThePassword". Change these in the code as needed. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TheEntry As Variant
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("TheRng")) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
TheEntry = Target.Value
Application.Undo
If InputBox("Please enter the password.") = "ThePassword" Then
Target.Value = TheEntry
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top