Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello and Good morning or evening,
I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you could use the userform's keydown event ...
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks for that, Where can I get a list of the numbers for keys? Would be a great help. Thanks again Greg B "Patrick Molloy" wrote in message ... you could use the userform's keydown event ... Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I'm not sure to be honest - its ages since i last looked at this to get 114 all I did was drop a label onto a userform Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Label1.Caption = KeyCode End Sub "Greg B" wrote in message ... Thanks for that, Where can I get a list of the numbers for keys? Would be a great help. Thanks again Greg B "Patrick Molloy" wrote in message ... you could use the userform's keydown event ... Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Wow that is pretty handy, Thanks Again
Greg B "Patrick Molloy" wrote in message ... I'm not sure to be honest - its ages since i last looked at this to get 114 all I did was drop a label onto a userform Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Label1.Caption = KeyCode End Sub "Greg B" wrote in message ... Thanks for that, Where can I get a list of the numbers for keys? Would be a great help. Thanks again Greg B "Patrick Molloy" wrote in message ... you could use the userform's keydown event ... Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Search KeyCodeConstants in Object browser (F2), select the one that interests you and look at the bottom. They are also in help but with hex values. Regards, Peter T "Greg B" wrote in message ... Thanks for that, Where can I get a list of the numbers for keys? Would be a great help. Thanks again Greg B "Patrick Molloy" wrote in message ... you could use the userform's keydown event ... Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Type keycodes in the VBA search box (upper right corner of window) and
select the first item, it is labeled "Keycode Constants (Visual Basic for Applications)". You can look for the key you want in the description column on the right and use the predefined constant listed on the left (this is more self-documenting than using the numerical value). So, once you find "F3 key" in the description, you can use predefined constant for that keycode, vbKeyF3, as shown in the left hand listing. So, instead of using... If KeyCode = 114 Then ' 114 is F3 you can use If KeyCode = vbKeyF3 Then instead. Note that the numerical values in the center column are given in mixed formats (Decimal or Hex) in the center column. The Hex numbers all start with 0x and if you wanted to use them (again, I am **strongly** recommending you use the predefined constants instead), you would have to change the 0x to &h which is VB's way of defining a Hex value. For example, the 0x72 shown for the F3 key would be &h72 inside your VB code (&h72 is the same as the decimal value of 114; vbKeyF3 also has a value of 114 which is why I recommend you use it in the first place). -- Rick (MVP - Excel) "Greg B" wrote in message ... Thanks for that, Where can I get a list of the numbers for keys? Would be a great help. Thanks again Greg B "Patrick Molloy" wrote in message ... you could use the userform's keydown event ... Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Everyone for the help and yes Rick I will follow that advice the
object browser explained it well. Greg B "Rick Rothstein" wrote in message ... Type keycodes in the VBA search box (upper right corner of window) and select the first item, it is labeled "Keycode Constants (Visual Basic for Applications)". You can look for the key you want in the description column on the right and use the predefined constant listed on the left (this is more self-documenting than using the numerical value). So, once you find "F3 key" in the description, you can use predefined constant for that keycode, vbKeyF3, as shown in the left hand listing. So, instead of using... If KeyCode = 114 Then ' 114 is F3 you can use If KeyCode = vbKeyF3 Then instead. Note that the numerical values in the center column are given in mixed formats (Decimal or Hex) in the center column. The Hex numbers all start with 0x and if you wanted to use them (again, I am **strongly** recommending you use the predefined constants instead), you would have to change the 0x to &h which is VB's way of defining a Hex value. For example, the 0x72 shown for the F3 key would be &h72 inside your VB code (&h72 is the same as the decimal value of 114; vbKeyF3 also has a value of 114 which is why I recommend you use it in the first place). -- Rick (MVP - Excel) "Greg B" wrote in message ... Thanks for that, Where can I get a list of the numbers for keys? Would be a great help. Thanks again Greg B "Patrick Molloy" wrote in message ... you could use the userform's keydown event ... Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 114 Then ' 114 is F3 endsale End If End Sub "Greg B" wrote in message ... Hello and Good morning or evening, I am wondering about something I have tried a piece of code I found on the web regarding hotkeys. It will work perfectly in the main excel sheet but I am hoping to have the capabilities when it has a userform showing. This code has been put in the open code of the worksheet where would I put it to be used in the userform? If this cant happen I am hoping to be able to press 1 button on the keyboard to shutdown the userform("Sales") and then execute the code for the next sale. Application.OnKey "{F3}", "endsale" Thanks In Advance Greg B |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Hotkeys... | Excel Discussion (Misc queries) | |||
assigning hotkeys | Excel Discussion (Misc queries) | |||
insert certain terms via hotkeys | New Users to Excel | |||
Disable Hotkeys | Excel Discussion (Misc queries) | |||
Macros and Hotkeys | Excel Programming |