|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub tj90()
Dim i, j, k, s1, s2, n, p, q, r, irow, irow1, irow2
Dim tepar, ar, br, cr, dr, er
Dim t
t = Timer
Dim d1, d2, d3, d4, d5, d6 As Object
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
Set d4 = CreateObject("scripting.dictionary")
Set d5 = CreateObject("scripting.dictionary")
Set d6 = CreateObject("scripting.dictionary")
irow1 = Sheets("汇总").[q65536].End(xlUp).Row
dr = Sheets("汇总").Range("q1:r" & irow1)
For p = 2 To irow1
d1(dr(p, 1)) = dr(p, 2)
Next
irow2 = Sheets("汇总").[t65536].End(xlUp).Row
er = Sheets("汇总").Range("t1:u" & irow2)
For q = 2 To irow2
d2(er(q, 1)) = er(q, 2)
Next
For i = 1 To Sheets.Count
If Sheets(i).Name <> "汇总" Then
irow = Sheets(i).[b65536].End(xlUp).Row
tepar = Sheets(i).Range("a1:d" & irow)
For j = 4 To irow
If tepar(j, 3) <> "" Then
If InStr(tepar(j, 3), "、") <> 0 Then
s1 = Left(tepar(j, 3), 4)
s2 = Right(tepar(j, 3), 4)
d3(s1) = d1(Left(tepar(j, 2), 2))
d5(s1) = d5(s1) + 0.5
d3(s2) = d1(Left(tepar(j, 2), 2))
d5(s2) = d5(s2) + 0.5
Else
d3(tepar(j, 3)) = d1(Left(tepar(j, 2), 2))
d5(tepar(j, 3)) = d5(tepar(j, 3)) + 1
End If
End If
If tepar(j, 4) <> "" Then
d4(tepar(j, 4)) = d2(Left(tepar(j, 2), 2))
d6(tepar(j, 4)) = d6(tepar(j, 4)) + 1
End If
Next
End If
Next
ReDim br(1 To 1000, 1 To 5)
r = Sheets("汇总").[a65536].End(xlUp).Row
cr = Sheets("汇总").Range("a1:j" & r)
For k = 3 To r
n = n + 1
br(n, 1) = d3(cr(k, 2))
br(n, 3) = d5(cr(k, 2))
br(n, 2) = d4(cr(k, 2))
br(n, 4) = d6(cr(k, 2))
br(n, 5) = br(n, 1) * br(n, 3) + br(n, 2) * br(n, 4)
Next
Sheets("汇总").[f3].Resize(1000, 5).ClearContents
Sheets("汇总").[f3].Resize(n, 5) = br
MsgBox Timer - t
End Sub
|
|