Excel 自动调整表格大小以适应屏幕
我有一个查询数据库的excel表,它返回的行数会波动Excel 自动调整表格大小以适应屏幕,excel,excel-2010,vba,Excel,Excel 2010,Vba,我有一个查询数据库的excel表,它返回的行数会波动 有人知道如何在行数发生变化时自动调整表格大小,使整个表格始终显示在屏幕上吗?听起来好像是指缩放。这艘方便的潜艇的所有学分 用法示例:调用ZoomToraneActiveSheet.cells1,1.currentregion,true 哇!谢谢分享。 Sub ZoomToRange(ByVal ZoomThisRange As Range, _ ByVal PreserveRows As Boolean) 'http://www.cp
有人知道如何在行数发生变化时自动调整表格大小,使整个表格始终显示在屏幕上吗?听起来好像是指缩放。这艘方便的潜艇的所有学分 用法示例:调用ZoomToraneActiveSheet.cells1,1.currentregion,true
哇!谢谢分享。
Sub ZoomToRange(ByVal ZoomThisRange As Range, _
ByVal PreserveRows As Boolean)
'http://www.cpearson.com/excel/zoom.htm
Dim Wind As Window
Set Wind = ActiveWindow
'
' Put the upper left cell of the range in the top-left of the screen.
'
Application.Goto ZoomThisRange(1, 1), True
With ZoomThisRange
If PreserveRows = True Then
.Resize(.Rows.Count, 1).Select
Else
.Resize(1, .Columns.Count).Select
End If
End With
With Wind
.Zoom = True
.VisibleRange(1, 1).Select
End With
End Sub