Excel

Hide horizontal and vertical scoll bars

Ease of Use

Easy

Version tested with

2000, 2003 

Submitted by:

Ken Puls

Description:

This entry shows how to to remove the horizontal and vertical scroll bars. 

Discussion:

There may be times where you do not want the scroll bars to show up on your worksheet, making it less likely that users will move around too much. This code removes those scroll bars and replaces them when the user moves to another workbook. 

Code:

instructions for use

			

Option Explicit Private Sub Workbook_Activate() 'Macro Purpose: Disable horizontal & vertical scroll bars With ActiveWindow .DisplayHorizontalScrollBar = False .DisplayVerticalScrollBar = False End With End Sub Private Sub Workbook_Deactivate() 'Macro Purpose: Restores users prior scroll bar settings With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True End With End Sub

How to use:

  1. Copy the code.
  2. Press Alt + F11 to open the Visual Basic Editor (VBE).
  3. In the project explorer, locate the ThisWorkbook object.
  4. Double click the ThisWorkbook object.
  5. Paste code into the right pane.
  6. Press Alt + Q to close the VBE.
  7. Save workbook before any other changes.
 

Test the code:

  1. We will need the workbook you just put the code in (we'll call it wb1) and another workbook( we'll call it wb2).
  2. Open wb2 and notice the scroll bars.
  3. Switch back to the wb1 and watch them disappear.
  4. Switch back to wb2 again, and watch the scroll bars show up again.
 

Sample File:

HideScrollBars.zip 7.09KB 

Approved by mdmackillop


This entry has been viewed 141 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express