Link to home
Start Free TrialLog in
Avatar of ExpExchHelp
ExpExchHelpFlag for United States of America

asked on

Excel VBA -- Set multiple scroll areas

In Excel, I'm using VBA (see below) to limit the scroll area upon opening a spreadsheet.

Private Sub Workbook_Open()

    'Locks Scroll Area
    Sheet1.ScrollArea = "C14:D20"
    
End Sub

Open in new window


This solution works great except that I need several (non-adjacent) cell ranges.    Unless not possible otherwise, I'd prefer to NOT use the "Lock cell/sheet" feature.

I attempted to tweak the code (see below); however, it throws an error message.   How can I use multiple cell ranges as part of the VBA below?

Private Sub Workbook_Open()

    'Locks Scroll Area
    Sheet1.ScrollArea = "C14:D20, D23, B28"
    
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Glenn Ray
Glenn Ray
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial