vba limit scroll area

bcselect

Board Regular
Joined
May 13, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
I have a workbook with 2 sheets where I need to limit scroll area. The areas are different on each sheet. The main sheet has macro buttons to enable viewing which includes limiting scroll area.
When a sheet is selected, it works fine. But when the other sheet is selected, it still displays the scroll area on the previous sheet. Below are the 2 macros. I've looked for a way to release scroll area limiting
but haven't found anything.

Sub Out_of_Town_Printout()
Application.ScreenUpdating = False
Sheets("Flight Printout").Select
Sheets("Flight Printout").ScrollArea = "AT1:CW47"
Range("CW47").Select
Range("AT4").Select
End Sub

Sub End_of_year_printout()
Application.ScreenUpdating = False
Sheets("Flight Printout").Select
Sheets("Flight Printout").ScrollArea = "DJ1:FJ47"
Range("FJ47").Select
Range("DJ7").Select
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You're using the same sheet reference
Sheets("Flight Printout").Select
Sheets("Flight Printout").ScrollArea = "DJ1:FJ47"

What is the sheet name for the End_Of_Year_Printout?
 
Upvote 0
I have a workbook with 2 sheets where I need to limit scroll area. The areas are different on each sheet. The main sheet has macro buttons to enable viewing which includes limiting scroll area.
When a sheet is selected, it works fine. But when the other sheet is selected, it still displays the scroll area on the previous sheet. Below are the 2 macros. I've looked for a way to release scroll area limiting
but haven't found anything.

Sub Out_of_Town_Printout()
Application.ScreenUpdating = False
Sheets("Flight Printout").Select
Sheets("Flight Printout").ScrollArea = "AT1:CW47"
Range("CW47").Select
Range("AT4").Select
End Sub

Sub End_of_year_printout()
Application.ScreenUpdating = False
Sheets("Flight Printout").Select
Sheets("Flight Printout").ScrollArea = "DJ1:FJ47"
Range("FJ47").Select
Range("DJ7").Select
End Sub
Same sheet. Different locations
 
Upvote 0
Consider using the worksheet activate event for your 'main' worksheet. By 'main', I mean the worksheet not named "Flight Printout"

VBA Code:
'Put in Main worksheet code module (not "Flight Printout")
Private Sub Worksheet_Activate()
    Me.ScrollArea = ""
    ThisWorkbook.Worksheets("Flight Printout").ScrollArea = "" '<- or WHATEVER you need it to be.
End Sub
 
Upvote 0
Solution
Consider using the worksheet activate event for your 'main' worksheet. By 'main', I mean the worksheet not named "Flight Printout"

VBA Code:
'Put in Main worksheet code module (not "Flight Printout")
Private Sub Worksheet_Activate()
    Me.ScrollArea = ""
    ThisWorkbook.Worksheets("Flight Printout").ScrollArea = "" '<- or WHATEVER you need it to be.
End Sub
GOT IT. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top