+ Reply to Thread
Results 1 to 25 of 25

KeyCodes for using Shift+Ctrl

  1. #1
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    KeyCodes for using Shift+Ctrl

    Hi,

    How could i use the keys shortcut im my userforms

    i have a userform contains some command-buttons like (Add, Amend, save, Exit, Next, Previous and delete)

    i have these codes for "Add" button and "Exit"
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    i need a code allow me to use these shortcuts:
    Ctrl + S
    or Shift + ctrl
    or Alt + T

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    Hi Mamud

    I usally modify this bit of old code

    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    Hi pike,

    In any event should i add that code ?? and what's function

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    keys shortcut im my userforms the code is in the user form
    can you attach the form?

  5. #5
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    Hi pike,

    In any event should i add that code ?? and what's function ??

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    Hi Mamud
    it allow short cut keys for userforms
    not knowing the userform i dont know how you need to apply and modify the code

  7. #7
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    Hi pike,

    sorry for duplication!

    I meant how can i specify the keys in that code ?

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: KeyCodes for using Shift+Ctrl

    If you are holding down Ctrl then the Shift variable supplied by the event will be 2; if holding down Shift key then it will be 1.
    So for Ctrl+C test if Shift = 2 and Keycode = 67 for example.
    Everyone who confuses correlation and causation ends up dead.

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    Hi Mamud
    I was thinking

    but after reading rompers post

    this can be adapted futhur
    Please Login or Register  to view this content.

  10. #10
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    or
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    hi pike, hi rompers

    the two updated codes dont work with me, pike
    but when i changed the shift from 2 to 1 in the second code, it works (Ctrl+F)

    Now, i need to know how can i use that code for (Ctrl+Shift)
    and what should i do to use (Alt) key (shift = ???)

    thx again

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: KeyCodes for using Shift+Ctrl

    Ctrl = 1
    Shift = 2
    Alt = 4

    add them up for combinations of the three.

  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    Maybe you can use the keyup

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    sorry pike, sorry rompers

    what is the code for using the function keys ??

    and I want the tables for the keycode numbers for all keys, if u have a link

    thx again

  15. #15
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: KeyCodes for using Shift+Ctrl

    Look up KeyCodeConstants in the Object Browser.

  16. #16
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    sorry again

    i cant write this code anymore

    really i need a help

    Please Login or Register  to view this content.
    nothing works...

  17. #17
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: KeyCodes for using Shift+Ctrl

    What is Keyhandler?

  18. #18
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    sorry again

    i cant write this code anymore

    really i need a help

    Please Login or Register  to view this content.
    nothing works...

  19. #19
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    Hi
    Since i didnt have your workbook I used KeyHandler which is the name of a listbox you used Form?

  20. #20
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    Quote Originally Posted by romperstomper View Post
    What is Keyhandler?
    I used that event from pike's posts !!!

  21. #21
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    please if anyone can correct that code

    Please Login or Register  to view this content.

  22. #22
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    you will need to change keyhandler to form

  23. #23
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: KeyCodes for using Shift+Ctrl

    I suspect you wanted Userform rather than KeyHandler.
    Also, you can't check if Shift is 1 and Shift is 2, you just check if Shift is 3.

  24. #24
    Forum Contributor
    Join Date
    09-01-2011
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    126

    Re: KeyCodes for using Shift+Ctrl

    did every keycode in the code is right or not

    i talk about (F1, Alt+D, Home, End, Delete, Page up and down)

  25. #25
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: KeyCodes for using Shift+Ctrl

    Button KeyCode
    Left Button 1
    Right Button 2
    Cancel 3
    Mbutton 4
    Back 8
    Tab 9
    Clear 12
    Return 13
    Shift 16
    Control 17
    Menu 18
    Pause 19
    Capital 20
    Escape 27
    Space 32
    PageUp 33
    PageDown 34
    End 35
    Home 36
    Left 37
    Up 38
    Right 39
    Down 40
    Select 41
    Print 42
    Execute 43
    Snapshot 44
    Insert 45
    Delete 46
    Help 47
    Numlock 144
    ScrollLock 145

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1