palaeontology
Active Member
- Joined
- May 12, 2017
- Messages
- 444
- Office Version
- 2016
- Platform
- Windows
Hi, I'm currently using the following code ... it allows me to double click on a cell in the range A8:A400, which then transfers the data from that cell over to the first available cell of a different sheet in the range LeftSubject!A8:A400. If double clicked again, it undoes that action.
However, the cells that the user might double click on (ie: range A8:A400 of the worksheet where the code is saved) I need them to be password protected, but, of course, the current code (shown above) doesn't work if those cells are protected.
Is there something I can add to the code that, in the act of double clicking, undoes the password, carries out the required action, then puts the password protection back into place ?
The password is ... Malibu00 ... if you need it for the code.
Very kind regards,
Chris
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)Dim LS As Range, c As Range, MySwitch As Boolean
If Intersect(Target, Range("A8:A400")) Is Nothing Then Exit Sub
Set LS = Sheets("LeftSubject").Range("A8:A400")
If Target.Interior.ColorIndex = 3 Then
Target.Interior.ColorIndex = xlNone
MySwitch = False
For Each c In LS
If c.Value = Target.Value Or MySwitch Then
c.Value = c.Offset(1, 0).Value
c.Offset(0, 4).Value = c.Offset(1, 4).Value
MySwitch = True
End If
If c.Value = "" Then Exit Sub
Next c
Else
Target.Interior.ColorIndex = 3
Set c = LS.Offset(-1).Find("")
c.Value = Target.Value
c.Offset(0, 4) = Now
End If
End Sub
However, the cells that the user might double click on (ie: range A8:A400 of the worksheet where the code is saved) I need them to be password protected, but, of course, the current code (shown above) doesn't work if those cells are protected.
Is there something I can add to the code that, in the act of double clicking, undoes the password, carries out the required action, then puts the password protection back into place ?
The password is ... Malibu00 ... if you need it for the code.
Very kind regards,
Chris