ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   key press event? (https://www.excelbanter.com/excel-programming/334679-key-press-event.html)

short_n_curly[_19_]

key press event?
 

i intend to programme code so that when the user presses spcae bar th
value in range J1 will go to the target cell i.e the one that space wa
pressed in a bit stuck so any help would be apprechiated thank

--
short_n_curl
-----------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...fo&userid=2157
View this thread: http://www.excelforum.com/showthread.php?threadid=38758


Wescotte

key press event?
 
I don't believe you can use the space bar because it starts to edit the
value of the cell.. However if you wanted to use the TAB key review the
code below. The reason I'm using the Workbook_Activate() portions is
becuase if the user has multiple workbooks open then the code will only
function if they are currently working on your workbook or else your
code will run for all open workbooks which you most likely don't want
to occur

Private Sub Workbook_Activate()
Call Workbook_SheetActivate(ActiveSheet)
End Sub

Private Sub Workbook_Deactivate()
Call Worksheet_Deactivate
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "JournalEntry" Then
Application.OnKey "{TAB}", "MySub"
Else
Application.OnKey "{TAB}"
End If
End Sub

Private Sub Worksheet_Deactivate()
Application.OnKey "{TAB}"
End Sub

Private Sub MySub
' Your Code Here

End Sub


short_n_curly[_20_]

key press event?
 

ok i have tried this but....
the sheet i wish this code to activate with is singular and will onl
be on one workbook i will be the user and no other workbook will b
active, i need the cose to be in sheet94 and it has to be addressed t
sheet94 and not the name of the sheet as i have code that will chang
the sheet name with other events, if space cannot be used then can th
shift button?

thanks for the speedy responc

--
short_n_curl
-----------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...fo&userid=2157
View this thread: http://www.excelforum.com/showthread.php?threadid=38758



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

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