|
参与一下。。。- Sub ykcbf() '//2024.2.19
- Dim arr, brr, d
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set ws = ThisWorkbook
- Set sh = ws.Sheets("Sheet1")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- sht.Delete
- End If
- Next
- arr = sh.[a1].CurrentRegion
- For j = 2 To UBound(arr, 2)
- s = Split(arr(1, j))(0)
- d1(s) = ""
- For i = 2 To UBound(arr)
- s1 = arr(i, 1)
- d2(s1) = s1
- ss = s & "|" & arr(i, 1)
- d(ss) = arr(i, j)
- Next
- Next
- For Each k In d1.keys
- Set sht = ws.Sheets.Add(after:=ws.Sheets(ws.Sheets.Count))
- m = 0
- ReDim brr(1 To UBound(arr), 1 To UBound(arr))
- With sht
- .Name = k
- .[a1] = arr(1, 1): .[a2] = k
- .[b1].Resize(1, d2.Count) = d2.keys
- arr = .UsedRange
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(1, j)
- If d.exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- With .UsedRange
- .Value = arr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .EntireColumn.AutoFit
- End With
- End With
- Next k
- sh.Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|