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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
 
Upvote 0
Solution
Yes, my bad... Thank you very much for the clarification.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,179
Members
448,871
Latest member
hengshankouniuniu

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