0
如果我在Excel中拆分工作表,它将创建两个相同的窗格。有没有办法将数据与它分离? 我需要在工作表上有两个窗格,每个窗格都需要有不同的滚动条。在左侧窗格中,我正在接受项目计划的输入,并在右侧窗格中显示甘特图。 我需要在Excel 2013中实现这一点。创建两个不同的窗格 - 拆分数据,同时将工作表拆分为两个窗格vba
如果我在Excel中拆分工作表,它将创建两个相同的窗格。有没有办法将数据与它分离? 我需要在工作表上有两个窗格,每个窗格都需要有不同的滚动条。在左侧窗格中,我正在接受项目计划的输入,并在右侧窗格中显示甘特图。 我需要在Excel 2013中实现这一点。创建两个不同的窗格 - 拆分数据,同时将工作表拆分为两个窗格vba
我不相信你可以达到你用窗格寻找的效果。当您在数据中滚动浏览时,窗格被设计为将标题行和列保留在屏幕上。
您需要打开第二个窗口,然后调整大小以填充屏幕的左半部分,另一个填充屏幕的右半部分。
尝试以下操作:
Option Explicit
Sub Demo()
' You may have to experiment to get these values correct for your system.
Const BorderHeight As Single = 30!
Const BorderWidth As Single = 15!
Const WindowLeft As Single = 1!
Const WindowTop As Single = 1!
Dim WindowHeight As Single
Dim WindowWidth As Single
Dim WshtNameLeft As String
Dim WshtNameRight As String
WshtNameLeft = "Sheet1" ' Rename as required
WshtNameRight = "Sheet2" ' Rename as required
' This demonstrates the macro does not depend on either of
' the target worksheets being active. Delete from final code.
Worksheets("Sheet3").Activate
With ActiveWindow
' Record full size of window
WindowHeight = .Height
WindowWidth = .Width
' Open a second window
.NewWindow
.WindowState = xlNormal
End With
Windows(ActiveWorkbook.Name & ":1").Activate
With ActiveWindow
' Size window to half width while allowing for borders. Position on left
.Height = WindowHeight - BorderHeight
.Left = WindowLeft
.Top = WindowTop
.Width = (WindowWidth - BorderWidth)/2
End With
Worksheets(WshtNameLeft).Select
Windows(ActiveWorkbook.Name & ":2").Activate
With ActiveWindow
' Size window to half width while allowing for borders. Position on right
.Height = WindowHeight - BorderHeight
.Top = WindowTop
.Width = (WindowWidth - BorderWidth)/2
' "+ 1" is to ensure windows do not overlap
.Left = WindowLeft + (WindowWidth - BorderWidth)/2 + 1
End With
Worksheets(WshtNameRight).Select
End Sub