2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

たった4行でExcelマクロを劇的に早くする方法

Posted at

はじめに

まったく本業ではありませんが、Excelのマクロを書く機会がありました。
とりあえず以下の4行を入れると処理に影響なく早くできたので共有します。

再描画を止める

Application.ScreenUpdating = False

イベントを止める

Application.EnableEvents = False

カーソルを砂時計にする

Application.Cursor = xlWait 

アラートを止める

Application.DisplayAlerts = False

サンプル

Sub sampleSub()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Cursor = xlWait
MsgBox "処理を開始します"
Application.DisplayAlerts = False
Call 呼びたい関数
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Cursor = xlDefault
MsgBox "処理を終了します"
End Sub

その他

基本的にカラム(セル)の挿入や削除は処理が重いので、セルのコピーや貼り付けなどで頑張った方がいいです。

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?