如何使Excel VBA宏运行更快

时间:2018-06-26 00:51:28

标签: excel vba excel-vba

我对VBA还是比较陌生,并且正在尝试使用非常长的VBA代码创建一个仪表板。该代码用于从多个工作表中查找值,以及用空白单元格替换任何#N / A错误或0,并取消保护工作表。代码本身可以运行,但是运行速度非常慢,并且冻结了Excel工作表。任何使代码运行更快的技巧将不胜感激!

Sub RunDashboard()

Sheets("Dashboard").Select
ActiveSheet.Unprotect

Range("D2:D" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C4:R10000C4"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,4,FALSE)"

Range("E2:E" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C5:R10000C5"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,5,FALSE)"

Range("F2:F" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C6:R10000C6"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,6,FALSE)"

Range("G2:G" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C7:R10000C7"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,7,FALSE)"

Range("H2:H" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C8:R10000C8"
Selection.FormulaR1C1 =         
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,8,FALSE)"

Range("I2:I" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C9:R10000C9"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,9,FALSE)"

Range("K2:K" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C11:R10000C11"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,11,FALSE)"

Range("P2:P" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C16:R10000C16"
Selection.FormulaR1C1 =     
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,16,FALSE)"

Range("T2:T" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C20:R10000C20"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,20,FALSE)"

Range("X2:X" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C24:R10000C24"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,24,FALSE)"

Range("Y2:Y" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C25:R10000C25"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,25,FALSE)"

Range("Z2:Z" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C26:R10000C26"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,26,FALSE)"

Range("AA2:AA" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C27:R10000C27"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,27,FALSE)"

Range("AB2:AB" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C28:R10000C28"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,28,FALSE)"

Range("AH2:AH" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C34:R10000C34"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,34,FALSE)"

Range("AI2:AI" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C35:R10000C35"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,35,FALSE)"

Range("AJ2:AJ" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C36:R10000C36"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,36,FALSE)"

Range("AK2:AK" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C37:R10000C37"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,37,FALSE)"

Range("AL2:AL" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C38:R10000C38"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,38,FALSE)"

Range("AM2:AM" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C39:R10000C39"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,39,FALSE)"

Range("AN2:AN" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C40:R10000C40"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,40,FALSE)"

Range("AO2:AO" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C41:R10000C41"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,41,FALSE)"

Range("AP2:AP" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C42:R10000C42"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,42,FALSE)"

Range("AQ2:AQ" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C43:R10000C43"
Selection.FormulaR1C1 = 
"=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,43,FALSE)"


Range("L2:L" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C11:R10000C11"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,12,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,3, FALSE))"

Range("M2:M" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C13:R10000C13"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,13,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,21, FALSE))"

Range("N2:N" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C14:R10000C14"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,14,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,22, FALSE))"


Range("O2:O" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C15:R10000C15"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,15,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,4, FALSE))"

Range("Q2:Q" & Cells(Rows.Count, "A").End(xlUp).Row).Select
ActiveCell.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,17,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,7, FALSE))"


Range("R2:R" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C18:R10000C18"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,18,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,18, FALSE))"

Range("S2:S" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C19:R10000C19"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,19,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,14, FALSE))"


Range("U2:U" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C21:R10000C21"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,21,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,5, FALSE))"


Range("V2:V" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C22:R10000C22"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,22,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,30, FALSE))"

Range("W2:W" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C23:R10000C23"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,23,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,31, FALSE))"


Range("AD2:AD" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C30:R10000C30"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,30,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,23, FALSE))"

Range("AE2:AE" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C31:R10000C31"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,31,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,24, FALSE))"

Range("AF2:AF" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Application.Goto Reference:="R2C32:R10000C32"
Selection.FormulaR1C1 = _

"=IF(RC2=""Deleted"",VLOOKUP(RC1,MasterAssetList!R2C1:R10000C45,32,FALSE), 
VLOOKUP(RC1, DataPull!R2C1:R10000C62,52, FALSE))"


Sheets("Dashboard").Select
On Error Resume Next
With Range("A2:A10000")
.Value = .Value
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With

Sheets("Dashboard").Select
Dim c As Range, LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For Each c In Range("A1:AQ1" & LastRow)
If Application.IsNA(c.Value) Then
c.Value = ""
End If
Next

Dim rng As Range
For Each rng In Range("A1:AQ1" & LastRow)
    If rng.Value = 0 Then
       rng.Value = ""
    End If
Next

Sheets("Dashboard").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
    , AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:=True

MsgBox "Your dashboard has finished running."

End Sub

3 个答案:

答案 0 :(得分:1)

  1. 为简化代码,我要做的第一件事是为A的最后一行保存一个变量:

    Dim intLastRow as integer
    intLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    

    这样,每次您使用这样的代码时:

    Range("D2:D" & Cells(Rows.Count, "A").End(xlUp).Row).Select
    Application.Goto Reference:="R2C4:R10000C4"
    Selection.FormulaR1C1 = "=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,4,FALSE)"
    

    可以简化为:

    Range("D2:D" & intLastRow).Select
    Application.Goto Reference:="R2C4:R10000C4"
    Selection.FormulaR1C1 = "=VLOOKUP(RC1,MasterAssetList!R2C1:R10000C41,4,FALSE)"
    

    这意味着您不会不断要求应用程序查找列的最后一行 A,只有一次。那应该节省大量时间。

  2. 正如J.Doe在评论中所说,请回顾您的代码,并将所有对“选择”的使用替换为硬编码范围。他们提供的This link对于避免使用“选择”的方式有很好的回答。

答案 1 :(得分:1)

除了@girlvsdata和@jdoe提出的建议之外,您还可以通过防止Ex​​cel在每次从一个单元格切换到下一个单元格或更改数据时更新显示并计算所有公式来加快处理速度。

在您的子标题开头执行此操作:

curl https://www.abuseipdb.com/check/51.38.41.14/json? 
key=my_key_here&days=7&verbose | jq

然后最后重新启用:

Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

除了其他建议外,这应该会有所帮助。

答案 2 :(得分:0)

谢谢@girlvsdata和@jdoe和@ seanW333-所有这些都非常有帮助,并使其运行异常快!下面的最终代码发布给了可能想要查看示例的任何人。

Sub RunDashboard2()

Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Dashboard").Unprotect
Sheets("DataPull").Unprotect
Sheets("MasterAssetList").Unprotect

Sheets("Dashboard").Range("C:C").Value = Sheets("DataPull").Range("B:B").Value
Sheets("Dashboard").Range("A:A").Value = Sheets("DataPull").Range("A:A").Value

Sheets("Dashboard").Select
Range("B2:B" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Selection.FormulaR1C1 = _
    "=IF(ISNA(VLOOKUP(RC1,MasterAssetList!R2C1:R10000C1,2,FALSE)),""Newly     Inserted"","""")"
Columns("B:B").Select
Range("B2").Activate
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=""Newly Inserted"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
    .Bold = True
    .Italic = False
    .ThemeColor = xlThemeColorAccent3
    .TintAndShade = -0.499984740745262
End With
With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent3
    .TintAndShade = 0.799981688894314
End With
Selection.FormatConditions(1).StopIfTrue = False

Sheets("MasterAssetList").Select
    Range("B2:B" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Selection.FormulaR1C1 = _
    "=IF(ISNA(VLOOKUP(RC1,Dashboard!R2C1:R10000C1,1,FALSE)),""Deleted"","""")"
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=""Deleted"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
    .Bold = True
    .Italic = False
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = -0.499984740745262
End With
With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = 0.799981688894314
End With
Selection.FormatConditions(1).StopIfTrue = False

Sheets("MasterAssetList").Select
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A1:$C1").AutoFilter Field:=2, Criteria1:="<>"
Range("A2:C2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

Sheets("Dashboard").Select
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste

Dim MAL As Worksheet
Set MAL = Sheets("MasterAssetList")

MAL.Select
Selection.RowHeight = 14.5

Sheets("Dashboard").Select
On Error Resume Next
With Range("A2:A10000")
.Value = .Value
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With

Dim DB As Worksheet
Set DB = Sheets("Dashboard")
DB.Select
Selection.RowHeight = 14.5

Dim intLastRow As Integer
intLastRow = Sheets("Dashboard").Cells(Rows.Count, "A").End(xlUp).Row

Range("D2:D" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,4,FALSE)"
Range("D2:D" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,4,FALSE)"
Range("E2:E" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,5,FALSE)"
Range("F2:F" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,6,FALSE)"
Range("G2:G" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,7,FALSE)"
Range("H2:H" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,8,FALSE)"
Range("I2:I" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,9,FALSE)"
Range("K2:K" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,11,FALSE)"
Range("P2:P" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,16,FALSE)"
Range("T2:T" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,20,FALSE)"
Range("X2:X" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,24,FALSE)"
Range("Y2:Y" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,25,FALSE)"
Range("Z2:Z" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,26,FALSE)"
Range("AA2:AA" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,27,FALSE)"
Range("AB2:AB" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,28,FALSE)"
Range("AH2:AH" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,34,FALSE)"    
Range("AI2:AI" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,35,FALSE)"
Range("AJ2:AJ" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,36,FALSE)"
Range("AK2:AK" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,37,FALSE)"
Range("AL2:AL" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,38,FALSE)"
Range("AM2:AM" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,39,FALSE)"
Range("AN2:AN" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,40,FALSE)"
Range("AO2:AO" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,41,FALSE)"
Range("AP2:AP" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,42,FALSE)"
Range("AQ2:AQ" & intLastRow).Formula = "=VLOOKUP($A2,MasterAssetList!$A$2:$AQ$10000,43,FALSE)"

Range("L2:L" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 12, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 3, FALSE))"
Range("M2:M" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 13, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 21, FALSE))"

Range("N2:N" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 14, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 22, FALSE))"

Range("O2:O" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 15, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 4, FALSE))"
Range("Q2:Q" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 17, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 7, FALSE))"

Range("R2:R" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2,     'MasterAssetList'!$A$2:$AQ$10000, 18, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 18, FALSE))"

Range("S2:S" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 19, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 14, FALSE))"

Range("U2:U" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 21, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 5, FALSE))"

Range("V2:V" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 22, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 30, FALSE))"

Range("W2:W" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 23, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 31, FALSE))"

Range("AD2:AD" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2,     'MasterAssetList'!$A$2:$AQ$10000, 30, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 23, FALSE))"

Range("AE2:AE" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 31, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 24, FALSE))"

Range("AF2:AF" & intLastRow).Formula = "=IF($B2=""Deleted"", VLOOKUP($A2, 'MasterAssetList'!$A$2:$AQ$10000, 32, FALSE), VLOOKUP($A2, 'DataPull'!$A$2:$BK$10000, 52, FALSE))"

Sheets("Dashboard").Select
On Error Resume Next
With Range("A2:A10000")
.Value = .Value
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With

Sheets("Dashboard").Activate
Dim c As Range
intLastRow = Cells(Rows.Count, "A").End(xlUp).Row

Range("A2:AQ2" & intLastRow).NumberFormat = "0;0;"""""
For Each c In Range("A2:AQ2" & intLastRow)
If Application.IsNA(c.Value) Then
c.Value = ""
End If
Next

Sheets("DataPull").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
    , AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:=True

Sheets("MasterAssetList").Protect DrawingObjects:=True, Contents:=True,     Scenarios:=True _
    , AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:=True

Sheets("Dashboard").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
    , AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:=True
Sheets("Dashboard").Select

MsgBox "Your dashboard has finished running."

Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub