Doubleclick event does not work on unprotected cell when sheet is protected

David1028

New Member
Joined
Feb 15, 2016
Messages
19
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True

ActiveCell.Value = ActiveCell.Offset(-1, 0)


End Sub

Why will the above code not work when I protect a worksheet? The cells i want to be able to doubleclick and copy above information are not locked?
Is there a workaround?

Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi David1028

What error do you get when double clicking the cells. This copies the cell from above so let's say A1 is unlocked and you want to copy it to B1...So is B1 unlocked?

Thanks

Dave
 
Upvote 0
Thanks for replying Dave, yes both cells are unlocked. I do not get an error message, the doubleclick just does not work. And yes there is data in the above cell.

Thank you again
 
Upvote 0
Where to you have the code placed David? Is it a sheet module, thisworkbook module or standard module?
 
Upvote 0
So in ThisWorkbook? OK

In the VBE open the immediate window by pressing Ctrl+G then paste this in. Then hit Enter.

Code:
Application.EnableEvents = true

Go back to your sheet. Does this change the behaviour of the double click event?
 
Last edited:
Upvote 0
Sorry, had to attend a meeting...
But no adding that code in the immediate window did not change anything
 
Upvote 0
Hi David,

Dave may not be back tonight as it is close to midnight for him.

Try this

Right click on the sheet you want this to run >> View code

Unlock the cell you are going to Double click on

Protect the sheet

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    ActiveCell.Value = ActiveCell.Offset(-1, 0)
End Sub

1) Are you trying to do this for a worksheet or workbook?
2) Macros are enabled, correct?
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top