Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keyboard event

Status
Not open for further replies.

bronc

Instructor
Aug 28, 2003
145
GB
I wish make Excel to repond as soon as i enter a character into the sheet ie a Key Press event of some sort. I see a Worksheet_Change event but that only fires after leaving the cell. I can't even see an API i might use. Any ideas please?

 
Have you tried,
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Regards,
dstrat
 




Here's a method that may work for you.

Add a Control Toolbox TEXTBOX to you sheet. Assign the Visible property to FALSE.

Use the Worksheet_SelectionChange event to position & size the textbox to the cell and make visible in the desired range of cells or not visible outside that range.

Use the control's key events to capture the information you want.

Caveat: Since you are in a control, the ENTER, TAB or ARROW keys will not navigate you to another cell. The user must make an explicit MOUSE SELECTION, in order to make another cell active.

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
nice thought but i want it to work for the whole column.

 
thanks also dstrat but i want the event to fire as soon as a single key is pressed not when i land on a cell.
 




"nice thought but i want it to work for the whole column."

Not a problem.

"thanks also dstrat but i want the event to fire as soon as a single key is pressed not when i land on a cell."

Two separate things.

1. When you "land on a cell", any cell in "the whole column", the Worksheet_SelectionChange event fires, and the textbox is positioned and sized to fit the cell and is made VISIBLE.

2. When "a single key is pressed", the textbox's key events fire and you can use these events to capture whatever info you need.


Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Have a look at the Application.OnKey method in conjunction with the Worksheet_SelectionChange event.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.OnKey " " 'Disable the space bar
    If (Target.Column = 1) Then
        Application.OnKey " ", "RespondToSpaceBar"
    End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top