Link to home
Start Free TrialLog in
Avatar of -Polak
-PolakFlag for United States of America

asked on

Can I use VBA to freeze detached horizontal and vertical panes?

For example, is it possible to force Excel to freeze-pane Columns A:B, Columns Z:Y: and Rows 1:2 ?
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Cells(2,3).select
    ActiveWindow.FreezePanes = True
Avatar of -Polak

ASKER

That will freeze Columns A:B and Row 1, but does nothing for Columns Z:Y....
You would have to select the appropriate cell with

Cells(2,3).select

and then do the freeze.
Avatar of -Polak

ASKER

If I try and put additional arguments into the cell select to freeze A:B & Y:Z and rows 1:2 I get a too many arguments error.

Again, I'm trying to freeze A:B, Y:Z, AND rows 1:2 simultaneously.....

It would be like Selecting cell C3 and AA3 and then freezing panes. Basically if a user were to scroll to the right past Y:Z both A:B and Y:Z would appear on the left side of the screen.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan 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
Avatar of -Polak

ASKER

Thank you, was hoping VBA could force creating a "window"-layer on top of the spreadsheet.
You could get round it with a manual tweak.

In the View tab select new Window and then Arrange All and choose Vertical and tick box for Windows of Active Workbook.

This will show the same sheet twice. Resize the left hand Window so that you can see only columns A & B and stretch the right hand window to fill the rest of the screen. Scroll the right hand window so that column Y is first column on sheet and then select AA3 and apply Freeze Panes.

In the View tab now select "View Side by Side" and "Synchronous Scrolling". The two windows will now scroll vertically in sync and to an extent horizontally; scrolling right on the Right hand pane won't scroll the left hand pane until after several scrolls.

Thanks
Rob H