本帖最后由 我行我速2008 于 2022-8-23 17:49 编辑
试试看行不行
Sub tt()
Dim ar, br, cr(1 To 4), r, c, i, x
Dim sh As Worksheet
Set sh = Sheet2
sh.[a1].CurrentRegion.Offset(2, 0).ClearContents
With Sheet1
ar = .[a1].CurrentRegion
For r = 5 To UBound(ar)
i = .Cells(r, 1).Cells.MergeArea.Count
For c = 4 To UBound(ar, 2)
If Application.CountA(.Cells(r, c).Resize(i, 1)) > 0 Then
br = .Cells(r, c).Resize(i, 1)
cr(1) = ar(r, 3): cr(2) = ar(r, 2)
cr(3) = ar(3, c): cr(4) = ar(4, c)
x = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
sh.Cells(x, 1).Resize(1, 4) = cr
sh.Cells(x, 5).Resize(1, i) = Application.Transpose(br)
End If
Next c
r = r + i - 1
Next r
End With
Set sh = Nothing
End Sub