[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