LoginSignup
14
19

More than 5 years have passed since last update.

Excel VBA 高速化における基本設定構文

Last updated at Posted at 2018-01-07

初投稿です。
Excel VBAで、高速化のための構文とか載ってますけど、なんか個別にぶつ切りで扱ってるものばかりなんですよね。私はいつも、下記の2つのマクロをセットにしてCallして使ってます。

Sub appSet()
'マクロ処理中に、描画など余計なものを省略して高速化
    With Application
        .ScreenUpdating = False '描画を省略
        .Calculation = xlCalculationManual '手動計算
        .DisplayAlerts = False '警告を省略。
'    .EnableEvents = False 'DisplayAlertsよりこちらを設定した方が良いのかな?
    End With
End Sub

Sub appReset()
'描画などの設定をリセット
    With Application
        .ScreenUpdating = True '描画する
        .Calculation = xlCalculationAutomatic '自動計算
        .DisplayAlerts = True '警告を行う
    End With
End Sub

要は、描画の省略、手動計算の設定がメインで、Withでまとめられるのが良いところ。一定以上のVBAユーザは死ぬほど使うはずなので、もうこうやってまとめるべきですねえ。
これはPERSONAL.XLSにも入れてて重宝してます。

14
19
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
14
19