方法三:
- Option Explicit
- Sub Crazy0qwer()
- Dim Ar, Br
- Dim I As Long, J As Long, X As Long, X1 As Long
- Dim N As Long, C As Long, R As Long, L As Long
- Dim S As String, S1 As String, SS As String
- Dim D As Object
- Set D = CreateObject("SCRIPTING.DICTIONARY")
- Ar = Sheets("SHEET1").Range("A1:A" & Sheets("SHEET1").[A65536].End(xlUp).Row)
- ReDim Br(1 To 1000, 1 To 100)
- D("AAA") = 1
- For I = 1 To UBound(Ar)
- If Ar(I, 1) <> "" Then
- L = InStr(Ar(I, 1), """")
- R = InStr(L + 1, Ar(I, 1), """")
- SS = Mid(Ar(I, 1), L + 1, R - L - 1)
- L = 2: C = 1
- Do
- L = InStr(L + 1, Ar(I, 1), "{")
- If L = 0 Then Exit Do
- R = InStr(L, Ar(I, 1), "}")
- X = L
- N = N + 1
- Br(N, 1) = SS
- Do
- X = InStr(X + 1, Ar(I, 1), ":")
- If X = 0 Or X > R Then Exit Do
- X1 = InStrRev(Ar(I, 1), """", X - 2)
- S = Mid(Ar(I, 1), X1 + 1, X - X1 - 2)
- If D.EXISTS(S) = False Then D(S) = C + 1: C = C + 1
- X1 = InStr(X, Ar(I, 1), ",")
- If X1 > R Or X1 = 0 Then X1 = R
- S1 = Replace(Mid(Ar(I, 1), X + 1, X1 - X - 1), """", "")
- X1 = D(S)
- If InStr(S1, "\u") Then
- Br(N, X1) = Right(S1, Len(S1) - InStr(S1, " ") + 1)
- S1 = Left(S1, InStr(S1, " ") - 1)
- S1 = Replace(S1, "\u", "&H")
- For J = Len(S1) - 5 To 1 Step -6
- Br(N, X1) = ChrW(Mid(S1, J, 6)) & Br(N, X1)
- Next
- Else
- Br(N, X1) = S1
- End If
- Loop
- Loop Until L = 0
- End If
- Next
- C = D.Count
- With Sheets("SHEET2")
- .Cells.Clear
- .[A1].Resize(1, C) = D.KEYS
- .[A2].Resize(N, C) = Br
- End With
- End Sub
复制代码 |