一个单元格中有自动换行的字段,如何通过VBA自动拆分,在下面插入一行,并将其他字段复制过来?

2025-03-29 04:08:09
推荐回答(2个)
回答1:


Sub 宏1()
Dim a  As Range
For Each a In [x:x]
a.Select: s = a: p = InStr(s, vbLf)
If p Then a.EntireRow.Copy: a.EntireRow.Insert Shift:=xlDown: a.Offset(-1) = Left(s, p - 1): a = Mid(s, p + 1)
If a = "" Then Application.CutCopyMode = False: Exit Sub
Next
End Sub

回答2:

A-W 不用动了?