• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel VBA - suggest workaround for scroll area run time error in Excel 2010, not in Excel 2019

Quark1

New Member
Hi to all,
I have

>>> use code - tags <<<
Code:
ThisWorkbook.Worksheets("SOMMA 1").ScrollArea = "C3:C302" in Private Sub Workbook_SheetActivate(ByVal Sh As Object)
And the sheet is protected.

I don't understand why, sometimes when the user opens the file, the visible columns are not A, B, C (as when I created and protected the sheet), etc but C, D, E, etc.
This happens to me with Excel 2019 that I have at home and with Excel 2010 that I have at work.

I thought of "forcing" a scroll by using this code:
Code:
ThisWorkbook.Worksheets("SOMMA 1").Select
Range("A1").Select
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

And this works well in Excel 2019 and 2010.

The problem arises when I want to freeze the scroll area and add this last row of code, because it works in Excel 2019 but not in Excel 2010 that I have in the office:

Code:
ThisWorkbook.Worksheets("SOMMA 1").ScrollArea = "C3:C302"
In Excel 2010 I have a run time error "not supported method" (I'm not sure about the actual error translation because I use Excel in Italian).

How could I write the code to define the scroll area and at the same time have it "fixed" all the times as it should be?

Thank you.
 
Last edited by a moderator:
Hi,​
no issue on my side with 2010 version, maybe you have badly protected the worksheet …​
Notice to 'force the scroll' only a single codeline is necessary just using Application.Goto method.​
 
Back
Top