0
0

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 1 year has passed since last update.

【VBA】AIに聞いてみたことメモ

Posted at

VBAでの処理時間を計測する方法

時間計測.
Sub MeasureExecutionTime()
    ' 開始時刻の取得
    Dim startTime As Double
    startTime = Timer
    
    ' 実行したい処理
    ' ...
    
    ' 実行時間の計算
    Dim executionTime As Double
    executionTime = Timer - startTime
    
    ' 結果の表示
    MsgBox "実行時間: " & Format(executionTime \ 60, "0") & "分" & Format(executionTime Mod 60, "00") & "秒"
End Sub

画像枚数チェック.
Sub CheckImageCount()
    ' フォルダパスと画像枚数の指定
    Const folderPath As String = "C:\Images"
    Const imageCount As Long = 5
    
    ' フォルダ内の画像ファイルを検索
    Dim fileCount As Long
    fileCount = 0
    Dim fileName As String
    fileName = Dir(folderPath & "\*.jpg")
    Do While fileName <> ""
        fileCount = fileCount + 1
        fileName = Dir
    Loop
    
    ' 画像枚数の確認
    If fileCount < imageCount Then
        Stop ' 画像枚数が指定枚数未満の場合、実行を一時停止
    End If
    
    ' その他の処理
    ' ...
End Sub
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?