少续貂,上需求:
将以下含有冒号句段分成新建的行数
eg:
解决方式,直接上宏命令
Sub 以分号为界限分割为新行()
Dim cell As Range
Dim text As String
Dim newText As Variant
Dim i As Integer
For Each cell In Selection
text = cell.Value
newText = Split(text, ";")
cell.Value = newText(0)
For i = 1 To UBound(newText)
cell.Offset(i, 0).EntireRow.Insert
cell.Offset(i, 0).Value = newText(i)
Next i
Next cell
End Sub
如果想以句号。为新建行,直接替换Split(text, ";")为Split(text, "。")就行啦,
后面的什么破折号,冒号,波浪号,都一样操作啦
最后上成果