Excel 创建两个不同的窗格-在vba中将工作表拆分为两个窗格时拆分数据
如果我在Excel中拆分工作表,它会创建两个相同的窗格。有没有一种方法可以将数据与其一起拆分? 我需要在一个工作表上有两个窗格,每个窗格都需要有不同的滚动条。在左侧窗格中,我获取项目进度的输入,在右侧窗格中,我显示甘特图。Excel 创建两个不同的窗格-在vba中将工作表拆分为两个窗格时拆分数据,excel,vba,Excel,Vba,如果我在Excel中拆分工作表,它会创建两个相同的窗格。有没有一种方法可以将数据与其一起拆分? 我需要在一个工作表上有两个窗格,每个窗格都需要有不同的滚动条。在左侧窗格中,我获取项目进度的输入,在右侧窗格中,我显示甘特图。 我需要在Excel 2013中实现这一点。我不相信你能用窗格实现你想要的效果。窗格的设计目的是当您在数据中滚动时,将标题行和列保持在屏幕上 您需要打开第二个窗口,然后调整其中一个窗口的大小以填充屏幕的左半部分,另一个窗口的大小以填充屏幕的右半部分 请尝试以下操作: Optio
我需要在Excel 2013中实现这一点。我不相信你能用窗格实现你想要的效果。窗格的设计目的是当您在数据中滚动时,将标题行和列保持在屏幕上 您需要打开第二个窗口,然后调整其中一个窗口的大小以填充屏幕的左半部分,另一个窗口的大小以填充屏幕的右半部分 请尝试以下操作:
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