ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Capture ENTER (https://www.excelbanter.com/excel-programming/342234-capture-enter.html)

Ed

Capture ENTER
 
I have some code in Worksheet_SelectionChange (ByVal Target As Range)

I want to redirect the activecell to another place when the user hits ENTER
(actually would like it to move the focus to my combobox).

I am not able (or don't understand) how to accomplish this. I have tried
the Target = 13 in other places in my code with comboboxes and keydown and it
works, but it doesn't work in this sub. Any suggestions?
--
Thanks - Ed

Jake Marx[_3_]

Capture ENTER
 
Hi Ed,

Ed wrote:
I have some code in Worksheet_SelectionChange (ByVal Target As Range)

I want to redirect the activecell to another place when the user hits
ENTER (actually would like it to move the focus to my combobox).

I am not able (or don't understand) how to accomplish this. I have
tried the Target = 13 in other places in my code with comboboxes and
keydown and it works, but it doesn't work in this sub. Any
suggestions?


The SelectionChange event will fire when the user's selection changes from
one cell or range to another. The Target argument is a Range object that
references the newly-selected range. So I don't think you need to trap the
Enter key - I think you could just trap the event and move to your ComboBox
based on the new selection.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]



Ed

Capture ENTER
 
I actually want two different things to happen. If the user uses TAB, he
should move to the next cell. If he hits ENTER, I want him to move back to
the first column and activate the combobox. This is why I wanted to capture
the ENTER.
--
Thanks - Ed


"Jake Marx" wrote:

Hi Ed,

Ed wrote:
I have some code in Worksheet_SelectionChange (ByVal Target As Range)

I want to redirect the activecell to another place when the user hits
ENTER (actually would like it to move the focus to my combobox).

I am not able (or don't understand) how to accomplish this. I have
tried the Target = 13 in other places in my code with comboboxes and
keydown and it works, but it doesn't work in this sub. Any
suggestions?


The SelectionChange event will fire when the user's selection changes from
one cell or range to another. The Target argument is a Range object that
references the newly-selected range. So I don't think you need to trap the
Enter key - I think you could just trap the event and move to your ComboBox
based on the new selection.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]




Jake Marx[_3_]

Capture ENTER
 
Ed,

OK - I think you'll have to use Application.OnKey then. The worksheet
object doesn't expose any type of keyboard events that you can trap.

'/ this maps Enter key to subroutine named "test"
Application.OnKey "{ENTER}", "test" '/ use {RETURN} for Return key

'/ this unmaps Enter key
Application.OnKey "{ENTER}"

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

Ed wrote:
I actually want two different things to happen. If the user uses
TAB, he should move to the next cell. If he hits ENTER, I want him
to move back to the first column and activate the combobox. This is
why I wanted to capture the ENTER.

Hi Ed,

Ed wrote:
I have some code in Worksheet_SelectionChange (ByVal Target As
Range)

I want to redirect the activecell to another place when the user
hits ENTER (actually would like it to move the focus to my
combobox).

I am not able (or don't understand) how to accomplish this. I have
tried the Target = 13 in other places in my code with comboboxes and
keydown and it works, but it doesn't work in this sub. Any
suggestions?


The SelectionChange event will fire when the user's selection
changes from one cell or range to another. The Target argument is a
Range object that references the newly-selected range. So I don't
think you need to trap the Enter key - I think you could just trap
the event and move to your ComboBox based on the new selection.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]





All times are GMT +1. The time now is 03:01 AM.

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