Public Sub 技巧() Dim i As Integer Dim wd As Window Set wd = ActiveWindow '创建3个新窗口 wd.NewWindow wd.NewWindow wd.NewWindow Windows.Arrange Arrangestyle:=xlArrangeStyleTiled '平铺窗口 MsgBox "已经创建了3个新窗口。下面将关闭这3个新窗口,并恢复原窗口。" For i = 1 To Windows.Count - 1 Windows(Windows.Count - 1).Close Next i ActiveWindow.WindowState = xlMaximizedEnd Sub
注释:
For i = 1 To Windows.Count - 1,此处运用for循环,for循环需注意,结束时要跟着next成对出现。