Option Explicit
Sub test()
Dim arr, i, j, m, t
arr = Range("a1").CurrentRegion.Offset(2).Value
ReDim brr(1 To Rows.Count, 1 To 2) As String
For i = 1 To UBound(arr, 1) - 2
If InStr(arr(i, 2), Space(1)) Then
t = Split(arr(i, 2), Space(1))
For j = 0 To UBound(t)
If Len(t(j)) Then
m = m + 1: brr(m, 1) = arr(i, 1): brr(m, 2) = t(j)
End If
Next
Else
m = m + 1: brr(m, 1) = arr(i, 1): brr(m, 2) = arr(i, 2)
End If
Next
With [d2] '输出位置自己修改
.Resize(Rows.Count - 1, 2).ClearContents
If m > 0 Then .Resize(m, 2) = brr
End With
End Sub |