如何在运行VBA宏后解冻Excel 2016?

时间:2017-03-20 14:46:20

标签: excel vba excel-vba

运行宏后,我的主要Excel功能不活动... 即。我不能改变文字的颜色,一切都很慢, 还有什么我应该打开/关闭以恢复正常操作? 当我关闭并打开时,一切似乎都是正确的。 这是我脚本末尾的文字。 我很感激你的帮助。

Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.CutCopyMode = False
Application.Calculate

在此处查看图片 unable to change color

Option Explicit

Sub Room_Results_up2_Click()
    Room_Results_up2 (False)

End Sub

Sub Room_Results_up2(ScreenUpdate As Boolean)

Dim ws As Worksheet
Dim zonecount As Long

If ScreenUpdate = False Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual
    Application.DisplayStatusBar = False
End If

Room_ResultsCopy False, False
TempUpdt False, False
TempUpdt2 False, False

Dim zakres As Range
Set zakres = Sheets("Room_Results").Columns("B")
Set zakres = zakres.SpecialCells(xlCellTypeConstants, xlTextValues)
If zakres.CountLarge = 0 Then Exit Sub
Dim kolumna As Long
Dim ileKolumn As Long
Dim komorka As Range
Dim wynik As Variant
ileKolumn = Range("B:CB").Columns.count
Dim f As Range '1

For Each komorka In zakres
    For kolumna = 2 To ileKolumn
        wynik = BezpVLOOKUP(komorka.Value, Sheets("Room_ResultsCopy").Range("B:BZ"), kolumna, False)
        If wynik <> "" Then
            Set f = Sheets("Room_ResultsCopy").Cells.Find(komorka.Value)
            Sheets("Room_ResultsCopy").Cells(f.Row, kolumna + 1).Copy
            Sheets("Room_Results").Cells(komorka.Row, kolumna + 1).PasteSpecial xlPasteAll

           Sheets("Room_Results").Cells(komorka.Row, kolumna + 1).Interior.Color = RGB(255, 255, 0)
        End If
    Next kolumna
Next komorka

Room_Results_RangeNames.Room_Results_RangeNames

If ScreenUpdate = False Then
    Application.DisplayStatusBar = True
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic

End If

zonecount = Sheets("Room_Results").Cells(Rows.count, "C").End(xlUp).Row
MsgBox "Update Done! " & vbNewLine & "Nr of Rows = " & zonecount & vbNewLine & "...by Michal"
Worksheets("Room_Results").Range("D10").Activate



End Sub

1 个答案:

答案 0 :(得分:0)

  

关闭屏幕更新以加速宏代码。您无法看到宏正在做什么,但它会运行得更快。   当宏结束时,请记住将ScreenUpdating属性设置回True。

Source

至于文字颜色不变,我不知道为什么。也许它与Application.EnableEvents = True有关。我看了this