- 帖子
- 145
- 主題
- 42
- 精華
- 0
- 積分
- 193
- 點名
- 0
- 作業系統
- Windows7
- 軟體版本
- Office2010
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2010-11-25
- 最後登錄
- 2026-6-10

|
小弟有一個排程的巨集,之前也是請教這裡的高手stillfish00協助解決的
不知道是不是電腦老舊還是資料量過大,使用一段時間之後這一段愈跑愈慢 ( 用公司的NB跑將近6~7分鐘 )
想請教各位高手是否有加速的方法,或者其實是因為其他部分我自行錄製拼湊出來的段落影響所以才會愈來愈慢?
ESOD_XT_AA.rar (472.05 KB)
Dim s1 As Long, s2 As Long
Dim cindex As Long
With Sheets("出貨日")
Set Rng = .Range(.[a1], .[a1].End(xlToRight).End(xlDown).Offset(, -1)) '[出貨日]資料範圍
End With
For Each c In Sheets("交期").Range("E2:E" & Sheets("交期").[a1].End(xlDown).Row) '[交期]資料填入範圍
If c.Offset(, -4).Value <> c.Offset(-1, -4).Value Then
cindex = 1
s1 = 0 '累積至前一批數量
s2 = 0 '累積出貨需求數量
Else
s1 = s1 + c.Offset(-1, -1).Value
End If
Do While s2 <= s1
cindex = cindex + 1
If Application.IsError(Application.VLookup(c.Offset(, -4).Value, Rng, cindex, False)) Then
Exit Do
Else
s2 = s2 + Application.VLookup(c.Offset(, -4).Value, Rng, cindex, False)
End If
Loop
If s2 <= s1 Then
c.Value = "NA"
Else
c.Value = Rng.Cells(1, cindex).Value
End If
Next
Set Rng = Nothing
'在E欄填入交期 |
|