Arun Singh gave a great answer to a similar question (Is there any event that fires when keys are pressed when editing a cell?). I want to set a flag to prevent execution of Selection_Change event if the user is scrolling with the arrow keys.
相关问题
- Excel sunburst chart: Some labels missing
- Error handling only works once
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
相关文章
- Get column data by Column name and sheet name
- programmatically excel cells to be auto fit width
- Unregister a XLL in Excel (VBA)
- Unregister a XLL in Excel (VBA)
- How to prevent excel from truncating numbers in a
- numeric up down control in vba
- Declare a Range relative to the Active Cell with V
- What's the easiest way to create an Excel tabl
I need to adjust the above to work with Worksheet_Change and Tab key as basically when tab key is pressed then changes the Target (when A2 is edited and Tab key pressed, Change event shows cell B2) which I want to avoid.
I have changed the key part to:
but am struggling to get any result on that?
When I press Tab key then my Change event does not call Sub StartKeyWatch() at all. also calling Sub StartKeyWatch() from Worksheet_Change directly does not seem to be doing anything...
what am I missing here?
thanks, mkvarious
It's pretty easy actually. I am demostrating it for UP and DOWN arrow key. You may add more to it like RIGHT/LEFT/TAB/ENTER etc... I have commented the part where you can add the keys.
Paste this in the worksheet code area
Paste this in a module
And here is something that you may need ;)
VBKey Code List
And Of course THIS msdn link for the key codes.