如图打开VBE编辑器,插入模块粘贴以下代码,将文件另存为.xlsm格式,在需要提取的单元格(如B1)输入=TS(A1) 下拉。
Function TS(rg As Range)
Application.Volatile True
Dim i%, a$, b$, n, m
On Error GoTo xxx
a = rg.Text
For i = 1 To Len(rg)
m = Application.Find("[", a)
n = Application.Find("]", a)
b = Mid(a, m, n - m + 1)
a = Application.Substitute(a, b, "")
m = ""
n = ""
Next
xxx:
TS = a
End Function