Board logo

標題: 取文字檔中,特定字元後之文字 [打印本頁]

作者: txiec    時間: 2011-12-9 09:46     標題: 取文字檔中,特定字元後之文字

各位大大,,,

再麻煩..有點難,搞不出來.

1. 連續取文字檔中,特定字元後之文字,
2. 取完DATA ,移至其他資料夾
3. 取之前,從最下行,開始置入..


感恩


[attach]8762[/attach]
作者: Hsieh    時間: 2011-12-9 11:36

回復 1# txiec
  1. Sub Ex()
  2. Dim ar()
  3. fd = ThisWorkbook.Path & "\"
  4. fs = Dir(fd & "*.txt")
  5. Do Until fs = ""
  6. Open fd & fs For Input As #1
  7. Do Until EOF(1)
  8.    Line Input #1, mystr
  9.    If mystr <> "" Then
  10.    a = Split(mystr, "=")
  11.    If a(0) = "SERIAL" Then r = a(1)
  12.    If a(0) = "SPEC" Then p = a(1)
  13.    If a(0) = "Total QTY" Then t = a(1)
  14.    If InStr(a(0), "SUPPLY") > 0 Then y = a(1)
  15.    If InStr(a(0), "QTY-") > 0 Then q = a(1)
  16.    If r <> "" And p <> "" And t <> "" And y <> "" And q <> "" Then
  17.    ReDim Preserve ar(s)
  18.    ar(s) = Array(r, p, t, y, q)
  19.    s = s + 1
  20.    y = "": q = ""
  21.    End If
  22.    End If
  23. Loop
  24. Close #1
  25. fs = Dir
  26. Loop
  27. [A65536].End(xlUp).Offset(1, 0).Resize(s, 5) = Application.Transpose(Application.Transpose(ar))
  28. End Sub
複製代碼

作者: txiec    時間: 2011-12-9 14:51

感謝版主...


真的是太讚....




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)