|
练手,不包售后。科学计数法自己去搞吧:D
Sub text()
Dim arr, brr(1 To 1000000, 1 To 7), crr
Dim x, k
Dim dic, key
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set dic = CreateObject("scripting.dictionary")
Set fso = CreateObject("scripting.filesystemobject")
For Each f In fso.getfolder(ThisWorkbook.Path).Files
If InStr(f.Name, ThisWorkbook.Name) = 0 Then
With Workbooks.Open(f)
arr = .Sheets(1).UsedRange
.Close False
End With
For x = 2 To UBound(arr)
key = arr(x, 14)
If Not dic.exists(key) Then
dic(key) = dic.Count + 1
brr(dic(key), 1) = arr(x, 14)
brr(dic(key), 2) = arr(x, 4)
brr(dic(key), 3) = arr(x, 6)
brr(dic(key), 4) = arr(x, 8)
brr(dic(key), 5) = arr(x, 19)
brr(dic(key), 6) = arr(x, 10)
brr(dic(key), 7) = brr(dic(key), 5) & "/" & brr(dic(key), 6)
Else
If InStr(brr(dic(key), 2), arr(x, 4)) = 0 Then
brr(dic(key), 2) = brr(dic(key), 2) & ";" & arr(x, 4)
brr(dic(key), 3) = brr(dic(key), 3) & ";" & arr(x, 6)
brr(dic(key), 4) = brr(dic(key), 4) & ";" & arr(x, 8)
End If
brr(dic(key), 5) = brr(dic(key), 5) + arr(x, 19)
brr(dic(key), 6) = brr(dic(key), 6) + arr(x, 10)
brr(dic(key), 7) = brr(dic(key), 5) & "/" & brr(dic(key), 6)
End If
Next
End If
Next f
crr = Sheets(1).UsedRange
For k = 2 To UBound(crr)
If dic.exists(crr(k, 2)) Then
crr(k, 36) = brr(dic(crr(k, 2)), 2)
crr(k, 37) = brr(dic(crr(k, 2)), 3)
crr(k, 38) = brr(dic(crr(k, 2)), 4)
crr(k, 39) = brr(dic(crr(k, 2)), 7)
End If
Next
Sheets(1).UsedRange = crr
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub |
|