Recalculate Macro and Progress Bar





0
Date Submitted Sat. Dec. 20th, 2008 3:10 AM
Revision 1 of 1
Beginner suin
Tags excel | macro | VBA
Comments 0 comments
This macro is recalculating selected cells with showing the progress bar in bottom status bar.

Progress bar example :

しばらくお待ちください。再計算しています。| ***_______ | 35% | 35/100 |

Sub 選択部分再計算()

    Dim Total As Integer
    Dim Counter As Integer
   
    Total = Selection.Cells.Count
    Counter = 1

    For Each SelectedCell In Selection
   
        SelectedCell.Calculate
       
        Counter = Counter + 1
       
        Application.StatusBar = "しばらくお待ちください。再計算しています。 " & ProgressView(Counter, Total)
   
    Next

    Application.StatusBar = False
   
    MsgBox ("再計算が完了しました。")

End Sub

Function ProgressView(Now As Integer, Total As Integer)

    Dim Per As Integer
    Dim Msg As String
    Dim Bar As String

    Per = Int(Now / Total * 100)

    Select Case Per
        Case Is >= 90
            Bar = "**********"
        Case Is >= 80
            Bar = "*********_"
        Case Is >= 70
            Bar = "********__"
        Case Is >= 60
            Bar = "*******___"
        Case Is >= 50
            Bar = "******____"
        Case Is >= 40
            Bar = "*****_____"
        Case Is >= 30
            Bar = "***_______"
        Case Is >= 20
            Bar = "**________"
        Case Is >= 10
            Bar = "*_________"
        Case Else
            Bar = "__________"
    End Select

    Msg = " | " & Bar & " | " & Per & "% | " & Now & " in " & Total & " | "

    ProgressView = Msg
   
End Function
 

Suin Yeze

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Votes Down