|
|
|
|
|
|
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()
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
End Sub
Private Sub Workbook_Deactivate()
With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With
End Sub
|
How to use:
|
- Copy the code.
- Press Alt + F11 to open the Visual Basic Editor (VBE).
- In the project explorer, locate the ThisWorkbook object.
- Double click the ThisWorkbook object.
- Paste code into the right pane.
- Press Alt + Q to close the VBE.
- Save workbook before any other changes.
|
Test the code:
|
- We will need the workbook you just put the code in (we'll call it wb1) and another workbook( we'll call it wb2).
- Open wb2 and notice the scroll bars.
- Switch back to the wb1 and watch them disappear.
- 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.
|
|