|
参与一下。。。
- Sub ykcbf() '//2024.9.21
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- p = ThisWorkbook.Path & ""
- f = p & "mark.txt"
- Set sh = ThisWorkbook.Sheets("Sheet1")
- zrr = Split(ReadUTFText(f), Chr(10))
- ReDim brr(1 To 1000, 1 To 2)
- Dim st As String
- Dim count As Integer
- On Error Resume Next
- For i = 0 To UBound(zrr)
- n = 0
- st1 = Split(zrr(i), ":")(0)
- m = m + 1
- For x = 0 To UBound(zrr)
- st = Split(zrr(x), ":")(1)
- n = n + tj(st, st1)
- Next
- brr(m, 1) = st1
- brr(m, 2) = n
- Next
- With sh
- .[a2:b1000].ClearContents
- .[a2].Resize(m, 2) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
- Function ReadUTFText(ByVal fn As String) As String
- With CreateObject("ADODB.Stream")
- .Type = 2
- .Mode = 3
- .Open
- .LoadFromFile fn
- .Charset = "UTF-8"
- .Position = 2
- ReadUTFText = .ReadText
- .Close
- End With
- End Function
- Function tj(ByVal strText As String, ByVal strSearch As String) As Integer
- Dim intCount As Integer
- Dim lngIndex As Long
- Dim strNextChar As String
- intCount = 0
- lngIndex = InStr(strText, strSearch)
- Do While lngIndex > 0
- strNextChar = Mid(strText, lngIndex + Len(strSearch), 1)
- If Not IsNumeric(strNextChar) Then
- intCount = intCount + 1
- End If
- lngIndex = InStr(lngIndex + Len(strSearch), strText, strSearch)
- Loop
- tj = intCount
- End Function
复制代码
|
|