加快Excel宏的6种方法



报名参加完整的Excel VBA课程并快速掌握VBA-https://www.udemy.com/excel-vba-course/?couponCode=YOUTUBE10 Excel宏是自动化任务和节省时间的绝佳方法。 但是随着增长,它们也会变慢。 该视频将显示6种加快Excel宏的方法,您现在可以实现这些宏。 这些技术应用于大大提高宏的效率。 如果您是现有的Excel VBA用户,则可能了解最多或全部。 请用您自己的技术发表评论。 在上找到更多很棒的免费教程。 http://www.computergaga.com与我们联系! LinkedIn►https://www.linkedin.com/company/18737946/ Facebook►http://www.facebook.com/computergaga Twitter►http://www.twitter.com/computergaga1。

9 comments
  1. Sub Add_row()

    ' Add_row Macro

    Application.Calculation = xlCalculationManual

    Application.ScreenUpdating = False

    Application.DisplayStatusBar = False

    Application.EnableEvents = False

    Range("A4:R4").Select

    Selection.ListObject.ListRows.Add (1)

    Range("A5:A8").Select

    Range("A8").Activate

    Selection.AutoFill Destination:=Range("A4:A8"), Type:=xlFillDefault

    Range("A4:A8").Select

    Range("B5:I5").Select

    Selection.AutoFill Destination:=Range("B4:I5"), Type:=xlFillDefault

    Range("B5:I5").Select

    Range("J5:R5").Select

    Selection.AutoFill Destination:=Range("J4:R5"), Type:=xlFillDefault

    Range("J5:R5").Select

    ActiveWindow.SmallScroll Down:=-2

    Application.Calculation = xlCalculationAutomatic

    Application.ScreenUpdating = True

    Application.DisplayStatusBar = True

    Application.EnableEvents = True

    End Sub

    Can you optimize this code for me with lesser operations please? Thank you

  2. Option Explicit

    Sub SpeedUpMacros()

    Dim i As Long
    Dim TotalRows As Long
    Dim CatRow As Long

    With Application
    .Caculation = xlCalculationManual
    .ScreenUpdating = False
    .DisplayStatusBar = False
    .EnableEvents = False
    End With

    i = 2
    TotalRows = Application.CountA(Worksheets("Sales").Range("A:A"))

    Worksheets("Sales").Select

    Do While i <= TotalRows

    CatRow = 2
    Do Until Worksheets("Categories").Cells(CatRows, 1).Value = ""

    If Cells(1, 6).Value = Worksheets("Categories").Cells(CatRows, 1).Value Then

    Cells(1, 10).Value = Cells(1, 10).Value * _
    Worksheets("Categores").Cells(CatRow, 2).Vaue

    Exit Do

    End If
    CatRow = CatRow + 1

    Loop

    i = i + 1
    Loop

    MsgBox "Done."

    With Application
    .Caculation = xlCalculationAutomatic
    .ScreenUpdating = True
    .DisplayStatusBar = True
    .EnableEvents = True
    End With

    End Sub

Comments are closed.