[VBA ] 运算效率请益(赠3000p币)

楼主: bright208 (la~尻枪~la)   2022-07-07 20:02:14
各位专家大家好
目标是要把特定列的储存格过滤出来
然后更新列的公式
我的列有一万行左右
程式码跑起来要两分钟....
我的程式码是哪里出问题吗?谢谢。
Sub UpdateStockValue()
Dim Sheet As Worksheet: Set Sheet = Worksheets("TEST")
Dim Table As ListObject: Set Table = Sheet.ListObjects(1)
Dim LastRow As Long: LastRow = Sheet.Range("A2").End(xlDown).Row
Dim data, cell As Range
Table.Range.AutoFilter 70, Array("Die attach", "M/C", "Packing
Materials", "Substrate"), xlFilterValues
Set data = Range("Z2:Z" & LastRow).SpecialCells(xlCellTypeVisible)
For Each cell In data
Cells(cell.Row, "Z").Formula = "=IFERROR(INDEX(mc.9!B:B,MATCH(D" &
cell.Row & ",mc.9!A:A,0)),0)"
Cells(cell.Row, "AL").Formula = "=Z" & cell.Row & "*AJ" & cell.Row &
"/100"
Next
Sheet.ShowAllData
Workbooks(1).RefreshAll
End Sub
给予最佳解答P币3000

Links booklink

Contact Us: admin [ a t ] ucptt.com