|
-
May 24th, 2005, 12:43 AM
#1
Thread Starter
New Member
Freeze panes in Excel
I have a macro that copies the contents of sheet A to sheet B. Everything else goes fine but I'm not able to move the freeze panes setting. For example, if there's cell D5 freezed in the sheet A, the macro should set the same cell freezed also in the sheet B.
I cannot move or copy the whole sheet, which would solve the problem. I can move or copy only the contents of the sheet.
The 'ActiveWindow.FreezePanes = True' command in the sheet B sets the right setting but to a wrong cell.
So basically my problem is that I'm not able to find the right cell in the sheet A. If I could do that, it would be easy to choose the same cell in the sheet B and then use the command above.
Anyone, any ideas? Thanks in advance!
-
May 24th, 2005, 10:21 AM
#2
Frenzied Member
Re: Freeze panes in Excel
karhatsu:
=======
This may help you ... there are up to 4 panes in a window.
Code:
Sub PaneTest()
MsgBox (ActiveWindow.Panes(1).VisibleRange.Address)
End Sub
Be warned that if you reference a pane that does not exist (such as Panes(0)), you get an error message:
"Run-time error '1004' Application-defined or object-defined error"
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
May 24th, 2005, 10:26 AM
#3
Frenzied Member
Re: Freeze panes in Excel
You'll also want to check out some other related properties of Windows:
Split, FreezePanes, SplitRow, SplitColumn
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
May 24th, 2005, 11:43 AM
#4
Frenzied Member
Re: Freeze panes in Excel
Here's another helpful hint ...
MsgBox (ActiveWindow.Panes.Count)
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
May 25th, 2005, 02:03 AM
#5
Thread Starter
New Member
Re: Freeze panes in Excel
Excellent, thanks for your help! This is what I finally used:
VB Code:
' test if the freeze panes setting is active
Sheets("original").Select
If (ActiveWindow.Panes.Count > 1) Then
' select the freeze panes cell
ActiveWindow.Panes(ActiveWindow.Panes.Count).VisibleRange.Activate
' get the cell range
freezePanesCell = ActiveCell.Address
' set freeze panes in the target sheet
Sheets("target").Select
Range(freezePanesCell).Activate
ActiveWindow.FreezePanes = False ' just in case
ActiveWindow.FreezePanes = True
End If
-
May 25th, 2005, 06:50 AM
#6
Frenzied Member
Re: Freeze panes in Excel
Mostly courtesy of "Definitive Guide to Excel VBA" by Michael Kofler! (a! Apress) Glad it helped you.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|