2
1

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 5 years have passed since last update.

【VBA】プログレスバーを表示する

Last updated at Posted at 2019-07-25

処理の中でプログレスバーを読んで表示させる自分用メモ。
これが
aaa2.png
こんな感じ。
aaa1.png
以下ソース。





' 100 × 1000 のセルに「1000」と出力し続ける関数
Sub sampleProgram()

    Dim i As Integer            ' 行カウンタ
    Dim j As Integer            ' 列カウンタ
    Dim intNum As Integer       ' 出力する数字
    Dim intProgress As Long     ' プログレスバー
    
    ' プログレスバー最初は「0」
    intProgress = 0
    ' プログレスバーのあるユーザフォームを表示
    Call showProgress
    ' 処理開始
    intNum = 1000
    For i = 1 To 100
        For j = 1 To 1000
            ActiveSheet.Cells(i, j).Value = intNum
        Next
        ' 1行処理したらプログレスバーを一つ進める
        intProgress = intProgress + 1
        UserForm1.ProgressBar1.Value = intProgress
    Next
    ' ユーザフォームを消す
    Unload UserForm1
    MsgBox "処理終了"
End Sub

' プログレスバーを表示するユーザフォームを呼び出す関数
Sub showProgress()
    UserForm1.Show vbModeless
    UserForm1.ProgressBar1.Min = 0
    UserForm1.ProgressBar1.Max = 100

End Sub

' シートクリアするボタン
Sub shtClear()
    Cells.Clear
End Sub


###参考文献
EXCELVBAでプログレスバーを作る

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?