|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 更新()
Set wk = ThisWorkbook
r1 = [c2]: r2 = [h2].Value
If r2 <= r1 Then arr = Range("e5:j" & r1)
ReDim brr(1 To UBound(arr), 1 To 6)
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xlsm")
Application.ScreenUpdating = False
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(p & f)
With wb.Sheets(1)
xm = .[i1]: n = .[c2]
m = 0
For i = 1 To UBound(arr)
If arr(i, 6) = xm Then
m = m + 1: r = Application.Match(xm, wk.Sheets(1).[j:j], 0)
For j = 1 To 5
brr(m, j) = arr(i, j)
Next
End If
Next
For i = 1 To m
If i = 1 Then
brr(i, 6) = r - 4
Else
brr(i, 6) = brr(i, 1) - brr(i - 1, 1)
End If
Next
brr(m + 1, 6) = .[d1] - brr(m, 1)
.Range("e5:i" & n - 4).ClearContents
.Range("e5").Resize(n - 4, UBound(brr, 2)) = brr
End With
wb.Close True
End If
f = Dir
Loop
Application.ScreenUpdating = True
MsgBox "数据更新完毕!"
End Sub
|
评分
-
1
查看全部评分
-
|