To disable pressing of Enter key on a sheet

S

Subodh

I have a worksheet
I want to disable pressing of Enter in the Sheet (ie. after pressing
Enter Key the selection of the cell should not go to the next cell)
and it should run a macro.
I have written the macro. Now, I want to run that macro when the User
presses the Enter Key.
It is similar to Keypress event in forms. I worked out and found that
there is code to disable the right click and to run other macro on
right click but i could not find any way to disable the enter key.
 
P

Peter T

Ensure "Move selection after enter" is not enabled in Options

You can trap when a user changes a cell entry, whether done with Enter or
any other means. Right-click the sheet tab, View code. That will take you to
the sheet module

In the top middle drop down select Worksheet
In the top right dropdown select Change

That will write the event stub for the Worksheet_Change event. Te argument
"Target" will refer to the cells that have just changed.

If you don't have much to do write your code in the event stub, otherwise
you could pass Target to a procedure in a normal module.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top