???? ID: 211736 - ????? ???????: 20 ??????? 2011 - ??????: 3.0

Excel ??? ??? ?????????? ??????? ?? ??? ??? ?????? ????? ????????? ???? ?? ??? ???? ????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
?? ???? ?? Microsoft Excel 97 ??????? ?? ???, ?????170782  (http://support.microsoft.com/kb/170782/ ) .

????? ?? ????? ???? ??? ????: ???? ??? Walkenbach

?? ????? ??

??? ?? ??????? ???? | ??? ?? ??????? ????

??????

??? ?? ?????? ???? ?? ??? ??? ???? ??? ???? ?? ?? ????????? ?????? ?? ??? Microsoft Visual Basic ??, ?? ???? indication ?????? ??? ?? progressing ?? ?????????? ?? ???? ?? ??? ?? ????? ?? ???? ????? ???? ?? ?? Microsoft Excel ??? ??? ?????????? ??????? ?? ??? ??? ?????? ????? ????? ?? ??? ???? ?????

???? ???????

Microsoft ???????????? ?????? ???? ???????? ?? ??? ??? ???? ??, ???? ??? ??? ?? ?????? ?? ?????????? ??? ??? ?????? ???? ?? ????.. ?????? ???????? ?????? ?? ???? ????? ???????? ?? ??? ???????? ????? ??? ?? ???? ?? ????? ???? ???.. ?? ??? ????? ?? ?? ?? ????? ?? ?? ??? ???????????? ???? ?? ?? ??????? ?? ?????? ??? ????? ????? ???????????? ?? ????? ?? ???? ???? ?? ??? ???? ?? ??? ??.. Microsoft ?????? ???????? ?? ????? ????????? ?? ???????????? ?? ?????? ??? ?????? ?? ???? ???.. ??, ?? ?? ???????? ?? ???? ??????? ?????????? ?? ?????? ???? ?? ??? ???????? ??????????????? ?? ?????? ?? ???????????? ????? ?? ??? ??????? ???? ??????..

?????????? ??????? ?????

????? ?????? ??? ???? Visual Basic ??????? populates ????? ?????? ???? ???? ?? ?? ??? ??????? ?????? ?? ?? ?????? ?? ??? ?? ?? ??? ???
  1. ??? ?? ????????????? ?? Excel ??? ??????
  2. Microsoft Office Excel 2003 ?? Excel ?? ????? ????????? ???, ????? ??????????? ????? ????,???????? ????-????? ????, ?? ???? ???Visual Basic ??????.

    Microsoft Office Excel 2007 ???, ????? ????Visual Basic????????:?? ????????????? ?? ????? ????..

    ???:????????? ???? ?? ????????????? ??? ??? ??, ????? ????? ?? ???? ????:
    1. Excel 2007 ?? ??????? ????, ????? ????Microsoft Office ????? ????-????? ????, ?? ???? ???Excel ??????.
    2. ?????Excel ??????????? ????? ???, ????? ????????????, ?? ???? ??? ?? ??? ???? ?? ??? ????? ???????? ??? ?????? ??? ????????? ?????.
  3. ????? ???????????? ???????? ??,UserForm.
  4. ????? ???????????????? ??????? ?? ????????? ?????
  5. ????? ?? ??? ????????? ????????????????? ???? ?? ??? ????? ???:
       Property        Value
       --------------------------------------------
       Caption         Now updating. Please wait...
    					
    ???:??????????? ???? ????? ???? ??, ????? ??????? ?????????? ????????????? ??..
  6. ????? ????????????????? ??????? ?? ????????? ?????
  7. ????? ?? ??? ????????? ?????????????????? ???? ?? ??? ????? ???:
        
       Property        Value
       -----------------------------
       Name            FrameProgress
    					
  8. ????? ???????? ????????????????????? ???
  9. ????? ?? ??? ????????? ????????????????? ???? ?? ??? ????? ???:
        Property        Value
        -------------------------------------
        Name            LabelProgress
        BackColor       &H000000FF&
        SpecialEffect   fmSpecialEffectRaised
    					

?????? ??? ?????

  1. ?????????? ??????? ?? ????? ?? ??? ???-????? ???????:????? ?????????? ??????? ?? ??? ???
  2. ??????? ??? ?? ??? ????? ??? ?????UserForm_Activate?????:
    Private Sub UserForm_Activate()
        ' Set the width of the progress bar to 0.
        UserForm1.LabelProgress.Width = 0
    
        ' Call the main subroutine.
        Call Main
    End Sub
    					
  3. ????? ???????????? ???????? ??,???????.
  4. ????????:??????? ?? ??? ????? ??? ????? ??? ?????:
    Sub ShowUserForm()
        UserForm1.Show
    End Sub
    
    Sub Main()
        Dim Counter As Integer
        Dim RowMax As Integer, ColMax As Integer
        Dim r As Integer, c As Integer
        Dim PctDone As Single
    
        Application.ScreenUpdating = False
        ' Initialize variables.
        Counter = 1
        RowMax = 100
        ColMax = 25
    
        ' Loop through cells.
        For r = 1 To RowMax
            For c = 1 To ColMax
                'Put a random number in a cell
                Cells(r, c) = Int(Rnd * 1000)
                Counter = Counter + 1
            Next c
    
            ' Update the percentage completed.
            PctDone = Counter / (RowMax * ColMax)
    
            ' Call subroutine that updates the progress bar.
            UpdateProgressBar PctDone
        Next r
        ' The task is finished, so unload the UserForm.
        Unload UserForm1
    End Sub
    
    Sub UpdateProgressBar(PctDone As Single)
        With UserForm1
    
            ' Update the Caption property of the Frame control.
            .FrameProgress.Caption = Format(PctDone, "0%")
    
            ' Widen the Label control.
            .LabelProgress.Width = PctDone * _
                (.FrameProgress.Width - 10)
        End With
    
        ' The DoEvents allows the UserForm to update.
        DoEvents
    End Sub
    					
  5. Excel ??? ???? ??????
  6. Excel 2003 ?? Excel ?? ????? ????????? ???, ????? ???? ?? ?????????????? ?????????????, ?? ???? ?????????.

    Excel 2007 ???, ????? ??????????????????:?? ????????????? ?? ????? ????..
  7. ???????????????? ????? ???, ????? ?? ??? ????? ????ShowUserForm?? ????-????? ????, ?? ???? ????????.
??? ??? ?????? ????? ?? ?? ????? ????? ????? ???? ??? ?????? ????? ?? ??? ??? ????? ???????subroutine populates the cells on the worksheet.

TheShowUserFormsubroutine shows the user form. The procedure that is attached to the?????? ????event of the user form calls the????????????? The?????subroutine populates cells with random numbers. Additionally, the subroutine calls theUpdateProgressBarsubroutine that updates theLabelcontrol on the user form.

???:When you use this technique, your macro takes just a bit longer to finish its intended tasks.

???? ???? ???? ??:
  • Microsoft Office Excel 2007
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Office Excel 2003
  • Microsoft Excel 2010
??????: 
kbinfo kbexpertisebeginner kbcode kbhowto kbmacro kbmt KB211736 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:211736  (http://support.microsoft.com/kb/211736/en-us/ )