2017-02-03 15 views
0

私はDBに問い合わせるExcelテーブルを持っています。返す行の数は変動します。画面に合わせて自動サイズ変更テーブル

テーブル全体が常に画面に収まるように、行の量が変更されたときにテーブルのサイズを自動的に変更する方法を知っている人はいますか?

答えて

1

ズームを参照しているように聞こえます。この便利なサブのすべてのクレジットはChip Pearsonになります。

使用例:call ZoomToRange(activesheet.cells(1,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 
+0

WOW。これを共有してくれてありがとう。 – eggwhites

関連する問題