KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 396
- Office Version
- 2016
- Platform
- Windows
Hi
Is it possible to make a VBA code that can lock and unlock cells in range D9 to D3669 with a password?
So, when someone try to write in a cell, a messenger box will be shown on the screen. Head line shout be "Limited access", an text "enter password to change this cell".
I use this VBA-code, I got by a friend to Lock a single cell. Maybe it can inspire.
All help will be appreciated.
Best regards
Klaus W
Is it possible to make a VBA code that can lock and unlock cells in range D9 to D3669 with a password?
So, when someone try to write in a cell, a messenger box will be shown on the screen. Head line shout be "Limited access", an text "enter password to change this cell".
I use this VBA-code, I got by a friend to Lock a single cell. Maybe it can inspire.
All help will be appreciated.
Best regards
Klaus W
VBA Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static Passed As Boolean
Dim P$
If Target.Address <> "$A$7" Or Passed Then Exit Sub
Do
P = InputBox(vbLf & vbLf & "Indtast adgangskode for at ændre denne celle:", "Begrænset adgang")
If P = "" Then Target(1, 2).Select: Exit Sub
Loop Until P = "A096"
Passed = True
End Sub