Run macro only in certain range double clicked

johnohio

New Member
Joined
May 12, 2005
Messages
48
Office Version
  1. 2016
Platform
  1. Windows
I have a spreadsheet where the sheet that is locked and if the user double clicks in a certain column I would like a macro to run.

for example..
there are 100 rows, hers are 3 of them...

1709214639567.png


if the user double clicks on on the first column a macro will run, double click on any other cell nothing happens.
The spreadsheet needs to be locked so the user cannot edit.


Thanks everyone
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Like this?
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Not Target.Column = 1 Then
   Cancel = True
   Exit Sub
End If

msgbox "Column 1 was double clicked"
Cancel = True 'may need this to suppress message re: changing protected sheet

End Sub
 
Upvote 0
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not Target.Column = 1 Then Cancel = True Exit Sub End If msgbox "Column 1 was double clicked" Cancel = True 'may need this to suppress message re: changing protected sheet End Sub
That does not work because the worksheet is locked.
 
Upvote 0
I protected the sheet but allowed user to select locked and unlocked cells. Perhaps you didn't have those settings? I'm rusty, but I thought that setting allowed users to do that but still not make changes.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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