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