Skip to content

Instantly share code, notes, and snippets.

@cress-cc
Created May 9, 2019 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cress-cc/7d6776db5eae2614d6a65b2dddcdb0d1 to your computer and use it in GitHub Desktop.
Save cress-cc/7d6776db5eae2614d6a65b2dddcdb0d1 to your computer and use it in GitHub Desktop.
VBAで処理時間を計測
Option Explicit
' システム起動後の経過時間をミリ秒で取得する関数。
' VBA標準のNow()とかだと秒までしか取れない。
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub Main()
Dim startTime As Long
Dim endTime As Long
startTime = GetTickCount()
Call 時間のかかる処理
endTime = GetTickCount()
Application.StatusBar = Format((endTime - startTime) / 1000, "0.00") & "[秒]"
MsgBox "完了"
Application.StatusBar = False
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment