|
参与一下。。。
- Sub ykcbf() '//2024.4.29
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("原始数据")
- r = .Cells(Rows.Count, "b").End(3).Row
- arr = .[a1].Resize(r, 4)
- End With
- ReDim brr(1 To 10000, 1 To 100)
- m = 1: n = 2
- brr(1, 1) = "序号": brr(1, 2) = "日期"
- For i = 2 To UBound(arr)
- s = CStr(arr(i, 2))
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = m - 1
- brr(m, 2) = CStr(arr(i, 2))
- End If
- s = CStr(arr(i, 3))
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(1, n) = s
- End If
- r = d(arr(i, 2)): c = d(arr(i, 3))
- brr(r, c) = arr(i, 4)
- Next
- With Sheets("转换结果")
- .Cells.Clear
- .[a1].Resize(1, n).Interior.Color = 49407
- .[c1].Resize(1, n - 2).NumberFormatLocal = "hh:ss"
- With .[a1].Resize(m, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|