- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 14# kulisung
¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim Txt As String, Fs As Object, d, A(), Tile As String, S As String, Stile As String, i, ii As Integer
- Txt = "d:\logfile.log" '¤å¦rÀɥؿý
- Set Fs = CreateObject("Scripting.FileSystemObject").OpenTextFile(Txt, 1)
- 'OpenTextFile ¤èªk ¶}±Ò¤@Ó«ü©wªºÀɮרöǦ^¤@Ó TextStream ª«¥ó¡A¸Óª«¥ó¥i¥Î©ó¹ïÀɮ׶i¦æŪ¨ú©Îªþ¥[¡C
- d = Split(Fs.readall, Chr(10))
- Fs.Close 'Ãö³¬¤å¦rÀÉ
- For i = 0 To UBound(d)
- If InStr(d(i), "---") Then
- If S <> "" Then
- If Len(Stile) > Len(Tile) Then Tile = Stile '½T©wøó¦ì¼ÐÀY
- ReDim Preserve A(0 To ii)
- A(ii) = S
- ii = ii + 1
- End If
- Stile = "" '²M°£°O¿ýøó¦ìªº¼ÐÀY
- S = "" '²M°£°O¿ý
- ElseIf InStr(d(i), ":") Then
- Stile = Stile & IIf(Stile <> "", "##", "") & Split(d(i), ":")(0) '°O¿ýøó¦ìªº¼ÐÀY
- S = S & IIf(S <> "", "##", "") & Trim(Replace(d(i), Mid(d(i), 1, InStr(d(i), ":")), ""))
- ElseIf InStr(d(i), ":") = 0 Then
- S = S & IIf(InStr(d(i - 1), ":"), "", Chr(10)) & Trim(d(i))
- End If
- Next
- ReDim Preserve A(0 To ii)
- A(ii) = S '³Ì«á¤@µ§¸ê®Æ
- If Len(Stile) > Len(Tile) Then Tile = Stile '½T©wøó¦ì¼ÐÀY
- With ActiveSheet
- .Cells.Clear
- .[A1].Resize(1, UBound(Split(Tile, "##")) + 1) = Split(Tile, "##") '¶×¤Jøó¦ì¼ÐÀY
- For Each i In A
- .Cells(.Rows.Count, 1).End(xlUp).Offset(1).Resize(1, UBound(Split(i, "##")) + 1) = Split(i, "##")
- '¶×¤J¬ö¿ý¸ê®Æ
- Next
- .Columns.EntireColumn.AutoFit '½Õ¾ãÄæ¼e
- End With
- End Sub
½Æ»s¥N½X |
|