ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trap whether it was TAB or arrow keys etc (https://www.excelbanter.com/excel-programming/328453-trap-whether-tab-arrow-keys-etc.html)

HotRod

Trap whether it was TAB or arrow keys etc
 
Is it possible to determine how a user exited a cell? I can track the last
cell address and new cell address but that doesn't tell me whether they
tabbed through the cell or clicked out. I want to set a default value for
columns and if the user TAB's through or presses the space bar and then
TAB's over I want to complete the cell with the default value.



Peter T

Trap whether it was TAB or arrow keys etc
 
There might be some API that would give you that information but I can't
think how to implement to your requirement. That aside I don't think it's
possible, if I'm wrong you can be pretty sure someone will step in.

Does it have to be a keyboard movement. You say you already have a method to
store the last selected cell, so why not compare it's address with the next
selected cell. If it's adjacent, and within the range you want to treat,
then treat it as if were selected with keyboard arrow or tab.

Something to bear in mind, if user tabs through a multicell selection, a
selection-change event is not triggered. However a change event is triggered
if tab or enter is used to complete the entry of the last active cell. But
note, the target cell that's returned in the event is the new active cell,
not the cell that's just changed. Confused!

Regards,
Peter T

"HotRod" wrote in message
...
Is it possible to determine how a user exited a cell? I can track the last
cell address and new cell address but that doesn't tell me whether they
tabbed through the cell or clicked out. I want to set a default value for
columns and if the user TAB's through or presses the space bar and then
TAB's over I want to complete the cell with the default value.





HotRod

Trap whether it was TAB or arrow keys etc
 
I've worked around this by having the user enter a "space" in the cell and
then continue on. Entering a space will enter the default value for that
column.


Quick other question I'm hoping you can help with when I use "Target.Column"
I get the number "1" how do I use the number to reference a cell at
A12 with the worksheets("mysheet").range().value ???



Tom Ogilvy

Trap whether it was TAB or arrow keys etc
 
rw = 12
col = Target.column
msgbox Worksheets("mysheet").Cells(rw,col).Value

--
Regards,
Tom Ogilvy

"HotRod" wrote in message
...
I've worked around this by having the user enter a "space" in the cell and
then continue on. Entering a space will enter the default value for that
column.


Quick other question I'm hoping you can help with when I use

"Target.Column"
I get the number "1" how do I use the number to reference a cell at
A12 with the worksheets("mysheet").range().value ???






All times are GMT +1. The time now is 10:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com