ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Panes sequence. Pane Index 2 & 3 depend on how panes are created (https://www.excelbanter.com/excel-programming/337505-panes-sequence-pane-index-2-3-depend-how-panes-created.html)

keepITcool

Panes sequence. Pane Index 2 & 3 depend on how panes are created
 

Hi guys,

I found following to be somewhat surprising, and it cost me several
hours before the coin dropped...

FYI & FWIW

The Panes.Collection does not always return the panes in the sequence:
1 2
3 4
when splits are set manually and the splitrow is set before the
splitcolumn...then and only then the sequence is different.
1 3
2 4

I'm sure MS$ will say it's by design. But I sure as hell would have
preferred if the panes collection's indexing was independent of the
sequence in which the panes are created.

Sub Demo()
With ActiveWindow
.FreezePanes = False: .SplitRow = 0: .SplitColumn = 0

'No manual splits
'Select FreezePanes
'Sequence is 1234

.VisibleRange.Cells(3, 4).Select
.FreezePanes = True
MsgPanes "FreezePanes only. (1234)"

'Manual splits

'SplitColumn is set BEFORE SplitRow
'Sequence is 1234
.SplitColumn = 3
.SplitRow = 2
MsgPanes "SplitColumn first (1234)"

'Manual: SplitRow is set BEFORE SplitColumn
'Sequence is 1324 !!!
.SplitRow = 2
.SplitColumn = 3
MsgPanes "SplitRow first (1324 !!!)"

End With
End Sub

Sub MsgPanes(sRemark$)
With ActiveWindow
MsgBox .Panes(1).VisibleRange.Address & vbLf & _
.Panes(2).VisibleRange.Address & vbLf & _
.Panes(3).VisibleRange.Address & vbLf & _
.Panes(4).VisibleRange.Address & vbLf, _
vbInformation, sRemark
.FreezePanes = False: .SplitRow = 0: .SplitColumn = 0
End With
End Sub

--
keepITcool

| www.XLsupport.com | keepITcool chello nl | amsterdam


All times are GMT +1. The time now is 10:08 AM.

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