|
Sub 更新1005()
Application.ScreenUpdating = False
Set wk = ThisWorkbook
tms = Timer
r1 = [g1]: r2 = [h2].Value
If r2 <= r1 Then arr = Range("e5:j" & r1)
ReDim brr(1 To UBound(arr), 1 To 6)
p = ThisWorkbook.Path & "\"
Select Case [j1] * 1
Case "0"
With Workbooks.Open(p & "0 三同.xlsm").Sheets(1)
xm = .[i1]: n = .[g1]
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) = .[c1] - brr(m, 1)
.Range("e5:i" & n - 4).ClearContents
.Range("e5").Resize(n - 4, UBound(brr, 2)) = brr
End With
Case "1"
With Workbooks.Open(p & "1 组三.xlsm").Sheets(1)
xm = .[i1]: n = .[g1]
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) = .[c1] - brr(m, 1)
.Range("e5:i" & n - 4).ClearContents
.Range("e5").Resize(n - 4, UBound(brr, 2)) = brr
End With
Case "2"
With Workbooks.Open(p & "2 组六.xlsm").Sheets(1)
xm = .[i1]: n = .[g1]
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) = .[c1] - brr(m, 1)
.Range("e5:i" & n - 4).ClearContents
.Range("e5").Resize(n - 4, UBound(brr, 2)) = brr
End With
Case "3"
f = Dir(p & "*.xlsm")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(p & f)
With wb.Sheets(1)
xm = .[i1]: n = .[g1]
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) = .[c1] - 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
Case Else
Exit Sub
End Select
Application.ScreenUpdating = True
MsgBox Format(Timer - tms, "0.000s")
End Sub |
评分
-
3
查看全部评分
-
|