LoginSignup
0
0

More than 3 years have passed since last update.

エクセルの行の高さ最適化するマクロ

Posted at
  • 行の境界線ダブルクリックするやつを自動で
  • 対象は全シート、全行
  • 除外したいシートを指定できる
module1

Sub rowfix()
    '行の高さ最適化する
    Dim Ws As Worksheet
    Dim x As Long

    For Each Ws In Worksheets
        '除外したいシート(demo1シート)はスキップ
        If Ws.Name = "demo1" Then
            GoTo CONTINUE
        End If
        'Ws.Rows.AutoFit '全行の高さ最適化する

        x = Ws.Rows.Count 'A2以下だけ最適化する
        Ws.Range("A2", "a" & x).EntireRow.AutoFit


CONTINUE: 'シートをスキップしたら飛んでくるラベル
    Next Ws
    MsgBox "終了"
End Sub

        'できない
        'Ws.Range("A2", Cells(Rows.Count, 1)).EntireRow.AutoFit
        'Ws.Range(Cells(2, 1), Cells(3, 1)).EntireRow.AutoFit
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0