|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 魂断蓝桥 于 2024-6-19 10:18 编辑
Option Explicit
Dim m, D
Sub a()
Sheet1.Range("A1:AA1").UnMerge
Dim c As Range, firstAddress, r As Range, arr, i&, j&, s$
Set D = CreateObject("Scripting.Dictionary")
m = 0
With Sheet1.UsedRange
Set c = .Find("副", lookat:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Call b(c.Address)
Do
Set c = .FindNext(c)
Call b(c.Address)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Sheet2.Activate
[b4:aa17] = ""
arr = [b4:aa17]
For i = 1 To UBound(arr)
For j = 1 To UBound(arr, 2)
s = i & "|" & j
arr(i, j) = D(s)
Next
Next
[b4].Resize(UBound(arr), UBound(arr, 2)) = arr
Set D = Nothing
With Sheet1.Range("A1:AA1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.MergeCells = True
End With
End Sub
Sub b(r)
Dim i&, j&, s$, arr
arr = Sheet1.Range(r).CurrentRegion
m = m + 1
For i = IIf(m = 1, 4, 3) To UBound(arr)
For j = 1 To UBound(arr, 2) Step 3
s = arr(i, j) & "|" & m
D(s) = arr(i, j + 2)
Next
Next
End Sub
|
评分
-
1
查看全部评分
-
|