Help us understand the problem. What is going on with this article?

Excelで、行の高さを自動でいい感じにする

More than 3 years have passed since last update.

Excelの行高さの自動調整についてです。

Excelシートの一番左の行番号のところをダブルクリックすると
その行の高さを自動で調整してくれますが、

大体の場合「ギュッと縦に詰まりすぎ」になります。
見づらいです。

そこで、「自動調整+余白の高さ」に自動調整するマクロを書きました。
ショートカットに登録すると快適です。

Sub NiceRowheight()
'余白設定
Const buf = 10
Application.ScreenUpdating = False
'とりあえず選択範囲の行高さをAutoFitする
Selection.Rows.AutoFit

'選択範囲が広すぎる時のために、データ最終行を獲得しておく
maxrow = Range("A1").SpecialCells(xlLastCell).Row

'その後、微妙に行高さを広げる。(1列目のみ処理)
For Each hoge In Selection.Columns(1).Cells
    hoge.RowHeight = hoge.RowHeight + buf

    '経過観察&終了判定
    i = i + 1
    If i Mod 2000 = 0 Then
        '終了判定(データの最終行を越えてたら終了する。)
        If hoge.Row > maxrow Then Exit For
        Application.StatusBar = i
        DoEvents
    End If
Next

Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした