ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scrolling to top left corner when window panes are frozen (https://www.excelbanter.com/excel-programming/371939-scrolling-top-left-corner-when-window-panes-frozen.html)

Joerg

Scrolling to top left corner when window panes are frozen
 
Hello world,

I have created a macro that scrolls all sheets of a workbook to the top left
corner (A1). Works as expected, however if the window of a sheet is set to
'Freeze panes', it doesn't.

I can see that Excel has a point: The top left cell is always visible when
panes are frozen, but I want the inner 'unfrozen' part to align to top left
as well. If I could determine the frozen area then I could handle these
cases by unfreezing - scrolling - refreezing, but I can't find a property
that would indicate the frozen range.

Example: If I activate B2, then do a Window = Freeze panes, then activate
the last cell in column B (B65536), the window shows A1 in the top left
corner, followed by A65503. I would like to show it A1, followed by A2. How
can I do it?

Here is the macro:

Sub ScrollToTopLeftCorner()
ActName = ActiveSheet.Name
For Each ws In Sheets
ws.Activate
ActiveWindow.ScrollIntoView 0, 0, 0, 0
Next
Sheets(ActName).Activate
End Sub


Thanks,

Joerg



Cush

Scrolling to top left corner when window panes are frozen
 
does this do what you are looking for:

ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

"Joerg" wrote:

Hello world,

I have created a macro that scrolls all sheets of a workbook to the top left
corner (A1). Works as expected, however if the window of a sheet is set to
'Freeze panes', it doesn't.

I can see that Excel has a point: The top left cell is always visible when
panes are frozen, but I want the inner 'unfrozen' part to align to top left
as well. If I could determine the frozen area then I could handle these
cases by unfreezing - scrolling - refreezing, but I can't find a property
that would indicate the frozen range.

Example: If I activate B2, then do a Window = Freeze panes, then activate
the last cell in column B (B65536), the window shows A1 in the top left
corner, followed by A65503. I would like to show it A1, followed by A2. How
can I do it?

Here is the macro:

Sub ScrollToTopLeftCorner()
ActName = ActiveSheet.Name
For Each ws In Sheets
ws.Activate
ActiveWindow.ScrollIntoView 0, 0, 0, 0
Next
Sheets(ActName).Activate
End Sub


Thanks,

Joerg





All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com