#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hotkeys

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Hotkeys

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hotkeys


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Hotkeys


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hotkeys

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Hotkeys


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Hotkeys

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hotkeys

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
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 Hotkeys... Connor Excel Discussion (Misc queries) 6 March 2nd 09 09:29 PM
assigning hotkeys tbird79 Excel Discussion (Misc queries) 2 December 21st 06 04:16 PM
insert certain terms via hotkeys texter New Users to Excel 3 March 10th 06 04:23 PM
Disable Hotkeys freekrill Excel Discussion (Misc queries) 1 November 24th 05 03:39 PM
Macros and Hotkeys Christopher Weaver Excel Programming 2 October 7th 03 05:33 PM


All times are GMT +1. The time now is 02:22 AM.

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"