Excel

Prevent Cell Selection / Scrolling

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Justinlabenne

Description:

Prevent cell selection and sheet scrolling 

Discussion:

If you do a lot of applications that require a backdrop "Dashboard" sheet, this snippet of code helps to place some more limits on user options. It disables the ability to select cells on the sheet, plus limits the scroll area to just one cell so the user cannot scroll vertically or horizontally. It also protects the sheet setting, but sets the User Interface to True so code can still run on the sheet if needed. Another method to customize the Excel environment and limit some user options. 

Code:

instructions for use

			

Option Explicit Sub StopSheet() ' Kill Cell Selection on Dashboard Sheet With Sheet1 'Code Name ' Disable scrolling by setting the scroll area to one cell .ScrollArea = Range("A1").Address ' Disable cell selection .EnableSelection = xlNoSelection ' Protect the sheet with user-interface set .Protect , , , , True End With End Sub Sub StartSheet() ' Reset the sheet With Sheet1 ' Unprotect the sheet .Unprotect .Range("A1").Select ' Re-open the scroll area .ScrollArea = Empty ' Allow for cell selection .EnableSelection = xlNoRestrictions End With End Sub

How to use:

  1. Open an Excel Workbook
  2. Copy the code
  3. Press Alt + F11 to open the Visual Basic Editor (VBE)
  4. Select INSERT > MODULE from the menubar
  5. Paste code into the right pane
  6. Press Alt+Q to return to Excel
  7. Save workbook before any other changes
 

Test the code:

  1. Go to TOOLS > MACRO > MACROS
  2. When the dialog appears, select {StopSheet}
  3. Press Run to disable the options
  4. Go to TOOLS > MACRO > MACROS
  5. When the dialog appears, select {StartSheet}
  6. Press Run to re-enable the options
 

Sample File:

DisableCellSelection.zip 8.92KB 

Approved by mdmackillop


This entry has been viewed 209 times.

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