|
本帖最后由 ykcbf1100 于 2024-1-29 08:03 编辑
参与一下。。。- Sub ykcbf() '//2024.1.29
- Dim arr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set reg = CreateObject("VBScript.Regexp")
- With Sheets("数据源")
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- arr = .Range("a1:af" & r)
- End With
- With reg
- .Global = True
- .Pattern = "(\d+)分钟"
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- If arr(i, j) <> Empty Then
- st = arr(i, j)
- Sum = 0
- Set mh = .Execute(st)
- For Each k In mh
- Sum = Sum + Val(k.Value)
- Next
- s = arr(i, 1) & "|" & arr(1, j)
- d(s) = Sum
- End If
- Next
- Next
- End With
- With Sheets("汇总")
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- arr = .Range("a1:af" & r)
- For i = 3 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(2, j)
- If d.Exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .Range("a1:af" & r) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|