我的Excel表格中有这种数据。有些人可能甚至没有"文字":
{asdd":" pagasasse"" qqwqwqww":" ACC-96d032ef-3cef-d692-9daa-05f08106e999"" pusherevent":"前夕-96d032ef-3cef-d692-9daa-05f08106e999""条目":[{" ID":" 122222222&# 34;,"时间":1493375728269,"消息":[{"发件人" {" ID":" 96d032ef- 3cef-d692-9daa-05f08106e999"}"收件人" {" ID":" 598113966995478"}"时间戳&#34 ;: 1493375727943"消息" {"中间":"中间$ cAAE_a0qfMcxh5WaBR1btCE7pLG5M"" SEQ":24608"文本&# 34;:" form __load F6910BF04A294FA59A89E398EF4B2E09"}}]}]}"
如何在" text":
之前删除所有内容答案 0 :(得分:0)
通过使用A1中的值来实现此结果的公式为:
=IFERROR(LEFT(RIGHT(A1,LEN(A1)-FIND("""text"":",A1,1)-7),FIND("""",RIGHT(A1,LEN(A1)-FIND("""text"":",A1,1)-7),1)-1),"text not found")
等效的VBA将是:
Function GetTextValue(str As String) As String
Dim tmpstr As String
If InStr(1, str, """text"":", vbTextCompare) = 0 Then
GetTextValue = "Text not found"
Else
tmpstr = Right(str, Len(str) - InStr(1, str, """text"":", vbTextCompare) - 7)
tmpstr = Left(tmpstr, InStr(1, tmpstr, """", vbTextCompare) - 1)
GetTextValue = tmpstr
End If
End Function
你可以称之为:
Sub test()
Dim str as string
str = ActiveSheet.Range("A1").value
str = GetTextValue(str)
ActiveSheet.Range("B1").value = str
End Sub
或在单元格中使用:=GetTextValue(A1)