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

-Polak
-Polak used Ask the Experts™
on
For example, is it possible to force Excel to freeze-pane Columns A:B, Columns Z:Y: and Rows 1:2 ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Cells(2,3).select
    ActiveWindow.FreezePanes = True

Author

Commented:
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.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
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.
No, you cannot do that. You can select either the leftmost columns or the topmost rows or both. Any other selection does not apply to freezing

Author

Commented:
Thank you, was hoping VBA could force creating a "window"-layer on top of the spreadsheet.
Rob HensonFinance Analyst

Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial