Returning reference of frozen cell

G

GilesT

I have a spreadsheet in which the Freeze Panes anchor may be set by a user.
I would like to know the cell location of where the freeze panes is, without
selecting any cells. How do I write code to check this?

Ideally, what I'm trying to do is something like this:

x = ActiveWindow.FreezePanes.Row
y = ActiveWindow.FreezePanes.Column

....except that "ActiveWindow.FreezePanes.Row" and
"ActiveWindow.FreezePanes.Column" is not a valid expression.

Would appreciate any help! Thanks.
 
R

Rick Rothstein \(MVP - VB\)

I have a spreadsheet in which the Freeze Panes anchor may be set by a user.
I would like to know the cell location of where the freeze panes is,
without
selecting any cells. How do I write code to check this?

Ideally, what I'm trying to do is something like this:

x = ActiveWindow.FreezePanes.Row
y = ActiveWindow.FreezePanes.Column

...except that "ActiveWindow.FreezePanes.Row" and
"ActiveWindow.FreezePanes.Column" is not a valid expression.

Would appreciate any help! Thanks.

I have never played around with this stuff myself, but a search through the
help files yielded this... ActiveWindow.SplitRow and
ActiveWindow.SplitColumn. There was also mention of panes and this seemed to
yield something positive (but I am unsure of how many panes are possible in
total)...

ActiveWindow.Panes(ActiveWindow.Panes.Count).ScrollRow

ActiveWindow.Panes(ActiveWindow.Panes.Count).ScrollColumn

where the scrollable area seems to be in the highest numbered pane (hence my
use of the count property).

Hope this helps.

Rick
 
D

Dave Peterson

Dim X as long
dim Y as long
With ActiveWindow.Panes(4)
Y = .ScrollColumn
X = .ScrollRow
End With
 
R

Rick Rothstein \(MVP - VB\)

Dim X as long
dim Y as long
With ActiveWindow.Panes(4)
Y = .ScrollColumn
X = .ScrollRow
End With

From my quick experiment with this "pane" stuff, I concluded using the
hard-coded 4 might fail if the spreadsheet were only split at the columns
only or the rows only (there would only be 2 panes then). My solution,
applied to your setup would be something like this...

Dim X as long
Dim Y as long
Dim MaxPane as Long
MaxPane = ActiveWindow.Panes.Count
With ActiveWindow.Panes(MaxPane)
Y = .ScrollColumn
X = .ScrollRow
End With

Rick
 
R

Rick Rothstein \(MVP - VB\)

Dim X as long
From my quick experiment with this "pane" stuff, I concluded using the
hard-coded 4 might fail if the spreadsheet were only split at the columns
only or the rows only (there would only be 2 panes then). My solution,
applied to your setup would be something like this...

Dim X as long
Dim Y as long
Dim MaxPane as Long
MaxPane = ActiveWindow.Panes.Count
With ActiveWindow.Panes(MaxPane)
Y = .ScrollColumn
X = .ScrollRow
End With

Actually, more in keeping with your original structure and the With
statement block, perhaps this instead...

Dim X As Long
Dim Y As Long
With ActiveWindow.Panes
Y = .Item(.Count).ScrollColumn
X = .Item(.Count).ScrollRow
End With

Although we lose the self-documenting MaxPane variable name this way.

Rick
 
D

Dave Peterson

I agree with you.



Rick Rothstein (MVP - VB) said:
From my quick experiment with this "pane" stuff, I concluded using the
hard-coded 4 might fail if the spreadsheet were only split at the columns
only or the rows only (there would only be 2 panes then). My solution,
applied to your setup would be something like this...

Dim X as long
Dim Y as long
Dim MaxPane as Long
MaxPane = ActiveWindow.Panes.Count
With ActiveWindow.Panes(MaxPane)
Y = .ScrollColumn
X = .ScrollRow
End With

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top