Do you find that users frequently scroll
outside the data range and onto blank areas of their worksheet? You
can create a macro that will automatically prevent them from moving
outside the used range on a worksheet. Follow these steps:
- Activate the worksheet.
- Right-click the sheet name tab on which you
want to limit scrolling and select View Code. - Enter the following code:
- Press [Alt][Q] and save the workbook.
Private Sub Worksheet_Activate()
Me.ScrollArea =
Range(Me.UsedRange, Me.UsedRange(2, 2)).Address
End Sub
Each time you activate the worksheet, this
macro will run automatically to prevent scrolling outside the used
range.
When you need to enter data outside the used
range, you will need to reset the scroll area. You can create a
shortcut key that activates a macro to do just that. Follow these
steps:
- Press [Alt]
[F11] - Select Insert | Module and enter the
following code at the prompt: - Press [ALT][Q]
- Press [ALT][F8] and Select
ResetScrollArea. - Click Options and assign a shortcut key.
Sub ResetScrollArea()
ActiveSheet.ScrollArea
=”
End Sub
Help users increase productivity by automatically signing up for TechRepublic’s free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.