Results 1 to 8 of 8

Thread: [RESOLVED] Disable worksheet scrolling

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    89

    Resolved [RESOLVED] Disable worksheet scrolling

    Hello All..

    It's been a while (bet you thought you got rid of me?)... I have just realized that Ctrl-PgUp and Ctrl-PgDown scrolls through the worksheets of an Excel project. I would like to disable this feature, possibly in my Workbook open code? Does anyone know how I would do this?

    Thanks in advance......

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Disable worksheet scrolling

    you could try using application.onkey to set those keys to do nothing
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Disable worksheet scrolling

    With or without code? Cause it is possible both ways...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    89

    Re: Disable worksheet scrolling

    Hello Koolsid,

    I'm not sure how to answer that...What I want is to enter a code in the "Workbook_Open()" of "This Workbook" so, I guess I want it with a code?

    Hope that makes sense......

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    89

    Re: Disable worksheet scrolling

    Hello WestConn1,

    I would try that but I'm afraid of disabling those keys as I need the page up-and down for other applications in this project...

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Disable worksheet scrolling

    you can specify if only with ctrl
    or pass the key actions with other workbooks
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Disable worksheet scrolling

    Quote Originally Posted by NPD071 View Post
    Hello Koolsid,

    I'm not sure how to answer that...What I want is to enter a code in the "Workbook_Open()" of "This Workbook" so, I guess I want it with a code?

    Hope that makes sense......
    Yes it does

    I'll share a little trick with you

    On my screen I can see 43 row approx. If you want to see only 25 rows then change 43 to 25. After you run the code, you will see that Page down doesn't work....

    Logic: I use "freeze pane" and then hide rest of the rows so that page down doesn't have any effect....

    vb Code:
    1. Private Sub Workbook_Open()
    2.     '~~> Change Row 43 to the row that you want
    3.     Rows("43:43").Select
    4.    
    5.     '~~> Freeze Pane
    6.     ActiveWindow.FreezePanes = True
    7.    
    8.     '~~> Hide rest of the row below Row 43
    9.     Rows("43:43").Select
    10.     Range(Selection, Selection.End(xlDown)).Select
    11.     Selection.EntireRow.Hidden = True
    12. End Sub

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    89

    Re: Disable worksheet scrolling

    Thanks Koolsid...that works great!

Posting Permissions

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



Click Here to Expand Forum to Full Width