|
源数据变化大,代码改一下吧。
- Sub ykcbf() '//2024.11.26 月份数据导入
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set d = CreateObject("Scripting.Dictionary")
- Set ws = ThisWorkbook
- p = ThisWorkbook.Path & ""
- bt = [{"制卡成功","已采集未提交制卡","卡商开户中","卡商开户失败","卡商制卡中"}]
- Dim tm: tm = Timer
- For Each f In fso.GetFolder(p).Files
- If Val(f.Name) Then
- d.RemoveAll
- fn = Val(Mid(fso.GetBaseName(f), 5, 2)) & "月"
- ReDim brr(1 To 10000, 1 To 100)
- m = 0
- Set wb = Workbooks.Open(f, 0)
- arr = wb.Sheets(1).UsedRange
- wb.Close 0
- For i = 2 To UBound(arr)
- If arr(i, 10) <> Empty Then
- s = arr(i, 10)
- p1 = IIf(arr(i, 17) = "3.0", 1, 0)
- p2 = IIf(arr(i, 17) = "2.0", 1, 0)
- p3 = IIf(arr(i, 18) = "已签发", 1, 0)
- Select Case Trim(arr(i, 14))
- Case Is = bt(1)
- c = 3
- Case Is = bt(2)
- c = 4
- Case Is = bt(3)
- c = 5
- Case Is = bt(4)
- c = 6
- Case Is = bt(5)
- c = 7
- End Select
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- brr(m, c) = p1
- brr(m, 8) = p2
- brr(m, 9) = p3
- Else
- r = d(s)
- brr(r, c) = brr(r, c) + p1
- brr(r, 8) = brr(r, 8) + p2
- brr(r, 9) = brr(r, 9) + p3
- End If
- End If
- Next
- With ws.Sheets(fn)
- .UsedRange.Offset(3).ClearContents
- .[a4].Resize(m, 9) = brr
- .[a4].Resize(m, 9).Borders.LineStyle = 1
- For i = 4 To m + 3
- .Cells(i, 2) = Application.Sum(.Cells(i, 3).Resize(, 6))
- Next
- .Cells(m + 4, 1) = "合计"
- For j = 2 To 9
- .Cells(m + 4, j) = Application.Sum(.Cells(4, j).Resize(m))
- Next
- End With
- End If
- Next f
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|