- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 102
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-4-28
               
|
8#
發表於 2010-6-17 20:03
| 只看該作者
本帖最後由 Hsieh 於 2010-6-18 08:26 編輯
回復 7# wsx24680 - Sub Ex()
- Dim Ar(), Mystr$, a$, s&, k%, fs$
- Cells = ""
- fs = Application.GetOpenFilename("Text Files (*.txt), *.txt")
- If fs = "False" Then MsgBox "請選擇文字檔": Exit Sub
- k = 2
- Open fs For Input As #1
- Do While Not EOF(1)
- Line Input #1, Mystr
- If Mystr <> "" And Not IsDate(Mystr) Then
- If InStr(Mystr, "=") = 0 And InStr(Mystr, "---") = 0 Then
- a = Mystr
- ElseIf InStr(Mystr, "=") > 0 Then
- ReDim Preserve Ar(s)
- Ar(s) = Array(a, Split(Mystr, "=")(0), "=", Split(Mystr, "=")(1))
- s = s + 1
- ElseIf InStr(Mystr, "---") > 0 Then
- Cells(1, k).Resize(s, 4).Value = Application.Transpose(Application.Transpose(Ar))
- k = k + 6: s = 0: Erase Ar
- End If
- End If
- Loop
- If s > 0 Then Cells(1, k).Resize(s, 4).Value = Application.Transpose(Application.Transpose(Ar))
- Close #1
- End Sub
複製代碼 |
|