我想从本文末尾包含的文本块中提取以下文本
提取的文本字符串将放在单独的工作表单元格中
旁注:文本块存储在单个工作表单元格中
10/15/2017 02:57:11 AM
FirstName LastName
Closed
10/15/2017 02:56:04 AM
ZFirst ZLast
Assigned
.......
仅供参考.....我要提取的文字是星号之间,但星号不包含在实际的文字字符串中。
=========================================
"**10/15/2017 02:57:11 AM FirstName LastName**
Changed Status to: **Closed**
Changed Restoration Category to: Software
Changed Configured Item Type to: Application
Changed Configured Item Category to: Software
**10/15/2017 02:56:04 AM ZFirst ZLast**
Changed Status to: **Assigned**
10/13/2017 05:21:35 AM YFirst YLast
Changed Status to: Suspend
Changed Date/Time Suspend Ends to: 10/18/17 13:30:00
Changed Suspend Reason to: Awaiting Customer Action
10/13/2017 12:03:12 AM ISAuto Prod005
Changed Status to: Assigned
10/11/2017 04:36:11 PM XFirst XLast
Changed Date/Time Suspend Ends to: 10/12/17 13:30:00
=============================================== ======
答案 0 :(得分:0)
实际上,您没有说明存储结果的位置,因此我将它们放入A列。这个子程序必须提供来自其他子程序的参数,我希望你知道如何去做。
Sub MySplit(sStr As String)
Dim i As Integer, j As Integer
Dim V, Y
sStr = Replace(sStr, "*", "")
V = Split(sStr, Chr(10))
For i = 0 To UBound(V)
Y = Split(V(i), " ")
For j = 0 To UBound(Y)
Range("A" & Cells.Rows.Count).End(xlUp).Offset(1, 0).Value = Y(j)
Next j
Next i
End Sub
不是很优雅的解决方案,但应该可行。