SeletionChange Event on ENTER error

jensslofstra

New Member
Joined
Sep 13, 2016
Messages
9
Hi everyone,
I was tinkering with the selectionchange event but came across an error.
"Cannot run the macro ''.xlsm'!DropdownList'. The macro may not be available in the workbook or all macros may be disabled."

I checked in my options if the trust center blocked my macro but it's on "enable all macros".
I saved the file as .xlsm so I don't see any problems with the file extension.

The code is as follows. And is written in Sheet1

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.OnKey "~", "DropdownList"
End Sub


Sub DropdownList(Cancel As Boolean)
    Target.Value = 1
End Sub

Does anyone have any idea how I can fix this?

Thanks anyways!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
The Dropdownlist routine needs to be in a normal module (that is not also called DropDownList) and should not take any arguments (you aren't using any anyway).
 
Upvote 0

Forum statistics

Threads
1,215,111
Messages
6,123,155
Members
449,098
Latest member
Doanvanhieu

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