以下是vlookup和countif的代码。
它需要超过5分钟才能完成,任何想法都可以加速我的宏?
With Sheets("HW INVENT")
lRow = .Range("A200000").End(xlUp).Row
Application.screenupdating=false
Application.Calculation = xlCalculationManual
.Range("C2:C" & lRow).FormulaR1C1 = "=VLOOKUP(RC[-1],LAST_WEEK_KPI!C[-1]:C,2,0)"
.Range("D2:D" & lRow).FormulaR1C1 = "=COUNTIF(R2C2:R" & lRow & ",RC[-2])"
.Range("F2:F" & lRow).FormulaR1C1 = "=VLOOKUP(RC[-1],LAST_WEEK_KPI!C[-1]:C,2,0)"
.Range("G2:G" & lRow).FormulaR1C1 = "=COUNTIF(R2C5:R" & lRow & ",RC[-2])"
Application.Calculation = xlCalculationAutomatic
Application.screenupdating=true
End With
任何想法为什么需要太长时间才能完成..在此先感谢..
答案 0 :(得分:1)
不是应用公式,而是尝试这样:
.Range("C2:C" & lRow).Value = Application.WorksheetFunction.VLookup(lookupvalue, Range("A:A"), 1, 0)
此方法Application.WorksheetFunction.VLookup(lookupvalue, Range("A:A"), 1, 0)
直接返回值。