Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    OnKey Didn't work... (XL2000 Sr-1 VBA)

    In the following excerpt, I intended for the OnKey lines to disable the use of Ctrl+PgUp and Ctrl+PgDn. It did not create any error messages when the file opened but it does not work. Both keyboard shortcuts still work as usual - what did I do wrong?

    Private Sub Workbook_Open()

    Sheets("DRS").ScrollArea = "Scroll_DRS"
    Application.OnKey "^{PGUP}", ""
    Application.OnKey "^{PGDN}", ""
    Call ChangeToThisMonth
    Sheets("Menu").Activate
    Range("scroll_Menu").Activate

    End Sub
    - Ricky

  2. #2
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OnKey Didn't work... (XL2000 Sr-1 VBA)

    Ricky,

    I pasted the second and third lines from your post into a new workbook, and they worked for me...either sequence will not switch sheets.

    If you put your cursor at the end of the third line and run the code to the cursor and then switch back to your spreadsheet, are the key sequences disabled?

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: OnKey Didn't work... (XL2000 Sr-1 VBA)

    Thanks for responding - I just saved the file, closed it and reopened it and the code worked as intended. Don't know why it wasn't working earlier.
    - Ricky

Posting Permissions

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