|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
是这个意思吗- Public Sub Most()
- Dim d As Object
- Dim arr As Variant
- Dim strKey As Variant
- Dim strItem As Variant
- Dim strArr() As String, m$, m1$
- Dim tr(1 To 2) As Integer
- Dim ttr() As Integer
- Dim l%, r%, x%, i%, j%
- Dim blnP As Boolean
- Set d = CreateObject("scripting.dictionary")
- r = [A65536].End(xlUp).Row
- arr = Range("A1:A" & r)
- For l = 2 To 5
- ReDim strArr(1 To r)
- tr(1) = 1
- For x = 1 To r
- tr(2) = x
- For i = 1 To Len(arr(x, 1))
- blnP = True
- m = Mid(arr(x, 1), i, l)
- If Len(m) = l Then
- For j = 1 To l
- m1 = Mid(m, j, 1)
- If Not (Asc(m1) > -20319 And Asc(m1) < -2050) Then
- blnP = False
- Exit For
- End If
- Next
- If blnP Then
- If d.Exists(m) Then
- ttr = d(m)
- If ttr(2) <> x Then
- ttr(1) = ttr(1) + 1
- ttr(2) = x
- d(m) = ttr
- End If
- Else
- d(m) = tr
- End If
- End If
- End If
- Next
- Next
- strKey = d.keys
- strItem = d.items
- d.RemoveAll
- tr(1) = 0
- tr(2) = 0
- For x = 0 To UBound(strItem)
- If strItem(x)(1) >= tr(1) Then
- tr(1) = strItem(x)(1)
- tr(2) = x
- End If
- Next
- If tr(1) > 1 Then
- Cells(l, 2).Value = l & "个的词"
- Cells(l, 3).Value = strKey(tr(2))
- Cells(l, 4).Value = "出现次数 " & tr(1)
- End If
- Next
- End Sub
复制代码 |
|