|
- Sub Test()
- Dim lngRows As Long, arr As Variant, lngRow As Long, lngCol As Long
- Dim objReg As Object, strTemp As String, strPat As String
- Dim objDic As Object, objTitle As Object, lngID As Long
- Dim strTitle As String, strContent As String
- Dim objMatchs As Object, objMatch As Object
- Set objDic = CreateObject("Scripting.Dictionary")
- Set objTitle = CreateObject("Scripting.Dictionary")
-
- lngRows = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
- arr = Sheet1.Range("A1:A" & lngRows)
-
- strPat = "([^:]*?):([\d.]*)"
- Set objReg = CreateObject("VBScript.RegExp")
- With objReg
- .Global = True
- .Pattern = strPat
- End With
- For lngRow = 2 To lngRows
- strTemp = arr(lngRow, 1)
- strTemp = Trim(strTemp)
- Set objMatchs = objReg.Execute(strTemp)
- For Each objMatch In objMatchs
- strTitle = objMatch.subMatches(0)
- strContent = objMatch.subMatches(1)
- objTitle(Trim(strTitle)) = ""
- strTitle = lngRow & "-" & Trim(strTitle)
- objDic(strTitle) = strContent
- Next
- Next
-
- lngRow = objTitle.Count
-
- Sheet1.Range("C1").Resize(1, lngRow) = objTitle.keys
-
- arr = Sheet1.Range("C1").Resize(lngRows, lngRow)
-
- For lngRow = 2 To lngRows
- For lngCol = 1 To UBound(arr, 2)
- strTemp = lngRow & "-" & arr(1, lngCol)
- arr(lngRow, lngCol) = objDic(strTemp)
- Next
- Next
-
- Sheet1.Range("C1").Resize(lngRows, UBound(arr, 2)) = arr
-
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|