Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default VBA - disable Up-Arrow key

Excel help for 2007 tells me that I may disable the Up-Arrow key with
Application.OnKey "{UP}","".

I've placed this code in several areas, within several sub-procedures,
including - UserForm_Activate() - and nothing disables the Up_Arrow key.

The application that I am dealing with is in selecting a choice from a
ComboBox. When I use the Slider-bar to position myself halfway through the
choices - I then use the Up-Arrow to make the first choice - and I'm
displaying the choice in a series of CheckBoxX.Caption (where X is an
explicit number from 1 to 13). I set CheckBoxX.Value = True and fill Caption
with text.

When a make a second choice by using the Up-Arrow again, I explicitly set
the Value and the Caption for the next CheckBox - and the system displays
this AND displays a Value = True and the Caption displaying text - on the
screen display of the Form.

HOWEVER - when I explicitly check the third CheckBox Value and Caption, the
Value is False and Caption is Null.

If I then make a third selection with the Up-Arrow key - I then have a
screen display of Checkbox entries that display screen entries for the last 3
selections - but in reverse order. This same reverse order presentation is
present after the second selection.

I'm capturing the number of selections made - 3 - however, the screen
displays 6 displays of CheckBox "data" - although the extraneous displays of
data for Value and Caption are out of sync with the actual contents of Value
and Caption.

I've written a sub-procedure that actually sets Value to False and Caption
to Null prior to the Selections with the Up-Arrow - but this doesn't change
the erroneous screen displays.

Down-Arrow and Mouse-clicks work just fine in the selection process and
screen displays.

I just want to disable the Up-Arrow - but Application.OnKey "{UP}","" fails
to disable the key

WHAT am I doing wrong?

Bob Allen
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default VBA - disable Up-Arrow key

Howdy folk,

After posting this question, I browsed around the Internet a tad and found a
solution. I now have placed that solution in my code. The code is -

Private Sub ComboBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
'Disable Up-arrow key - causing problems in ComboBox selections
If KeyCode = vbKeyUp Then KeyCode = vbNull
End Sub

Now the Up-Arrow key is disabled while the ComboBox has focus.

Thanks for looking at the issue.

Bob Allen

"Bob Allen" wrote:

Excel help for 2007 tells me that I may disable the Up-Arrow key with
Application.OnKey "{UP}","".

I've placed this code in several areas, within several sub-procedures,
including - UserForm_Activate() - and nothing disables the Up_Arrow key.

The application that I am dealing with is in selecting a choice from a
ComboBox. When I use the Slider-bar to position myself halfway through the
choices - I then use the Up-Arrow to make the first choice - and I'm
displaying the choice in a series of CheckBoxX.Caption (where X is an
explicit number from 1 to 13). I set CheckBoxX.Value = True and fill Caption
with text.

When a make a second choice by using the Up-Arrow again, I explicitly set
the Value and the Caption for the next CheckBox - and the system displays
this AND displays a Value = True and the Caption displaying text - on the
screen display of the Form.

HOWEVER - when I explicitly check the third CheckBox Value and Caption, the
Value is False and Caption is Null.

If I then make a third selection with the Up-Arrow key - I then have a
screen display of Checkbox entries that display screen entries for the last 3
selections - but in reverse order. This same reverse order presentation is
present after the second selection.

I'm capturing the number of selections made - 3 - however, the screen
displays 6 displays of CheckBox "data" - although the extraneous displays of
data for Value and Caption are out of sync with the actual contents of Value
and Caption.

I've written a sub-procedure that actually sets Value to False and Caption
to Null prior to the Selections with the Up-Arrow - but this doesn't change
the erroneous screen displays.

Down-Arrow and Mouse-clicks work just fine in the selection process and
screen displays.

I just want to disable the Up-Arrow - but Application.OnKey "{UP}","" fails
to disable the key

WHAT am I doing wrong?

Bob Allen

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 - Macro (VB) code for arrow down & arrow up Grindy Excel Discussion (Misc queries) 5 January 28th 09 04:30 AM
Using end-arrow down or end-arrow up in a macro Richard Champlin Excel Discussion (Misc queries) 2 September 20th 07 01:12 AM
why dont shift+arrow or ctrl+arrow work in 2007 Naguib Excel Discussion (Misc queries) 1 July 24th 07 04:40 PM
Arrow key dpal Excel Discussion (Misc queries) 2 May 2nd 07 06:18 PM
How to do the following by pressing the down arrow or up arrow key? cyberdude Excel Discussion (Misc queries) 4 December 14th 05 01:29 PM


All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"