Scroll area settings not saved after macro

tfdd

New Member
Joined
Jan 30, 2021
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
Can someone help me to find out why the following code is not keeping the scroll area permanent?

I used the Workbook_Open event procedure (in the "numbers" sheet module)

VBA Code:
Private Sub Workbook_Open()
Sheets("numbers").ScrollArea = "$A$5:$M$155"
End Sub

I have also tried this one in the worksheet:
VBA Code:
Private Sub Worksheet_Activate()
ActiveSheet.ScrollArea = "$A$5:$M$155"
End Sub


They both work when the macro is ran, but after saving the excel file, closing it and reopen it, the scroll area is reset, doesn't keep the properties of the macro.

Thanks!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

EXCEL MAX

Active Member
Joined
Nov 11, 2020
Messages
392
Office Version
  1. 2016
Platform
  1. Windows
Hello Tfdd,
Workbook_Open event is part of ThisWorkbook module, not sheet module.
In the Project explorer window select ThisWorkbook,
find Workbook_Open event in the code editor and insert this code there...

ThisWorkbook.PNG
 
Solution

tfdd

New Member
Joined
Jan 30, 2021
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
Yes, my bad... Thank you very much for the clarification.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,310
Messages
5,641,450
Members
417,210
Latest member
rins

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
Top