Excel VBA スニペット

'新たなイベント発生の抑制------
Application.EnableEvents = False

'元に戻す------
Application.EnableEvents = True
'手動計算
Application.Calculation = xlCalculationManual

'再計算の実行
Application.Calculate 

'自動計算
Application.Calculation = xlCalculationAutomatic
'計測開始
    Dim myspeed As Double
    Dim starttime As Double
    starttime = Timer
'---------------------------

'計測終了
   myspeed = Timer - starttime
   Debug.Print "処理時間:" & myspeed & ""
'---------------------------

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject") 
'上書き保存
Workbooks("Dummy.xlsx").Close SaveChanges:=True

'保存せずに保存
Workbooks("Dummy.xlsx").Close SaveChanges:=False
'指定したブックを開く(ドライブ名・・・拡張子)
Workbooks.Open Filename:="C:\・・・\test.xlsx"

'指定したブックを開き、オブジェクト指定
Dim wb as As Workbook
Set wb1 = Workbooks.Open(Filename:="C:\・・・\test.xlsx")

'最終行を取得する
cnt = Cells(Rows.Count, 1).End(xlUp).Row
'警告メッセージの停止
Application.DisplayAlerts = False

'警告メッセージを通常表示
Application.DisplayAlerts = True
'1秒間処理を中断する
Application.Wait Now + TimeValue("00:00:1")
Application.ScreenUpdating = False
Application.ScreenUpdating = True