- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 118
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-5-15
               
|
2#
發表於 2013-5-16 22:17
| 只看該作者
回復 1# leoman0002 - Sub ex()
- Dim arr()
- Dim Filename As Variant
- Dim i As Integer
- fs = Application.GetOpenFilename("僅能匯入csv格式,*.csv", , "ワ確定", , True) '改成複選檔案
- For Each f In fs '每個檔案迴圈
- p = Range("G65536").End(xlUp).Row + 1
- With CreateObject("Microsoft.XMLHTTP")
- .Open "GET", f, False
- .Send
- tt = .responsetext
- ss = Split(tt, vbCrLf)
- End With
- ReDim arr(0 To UBound(ss), 0 To 15)
- For i = 0 To UBound(ss)
- s1 = Split(ss(i), ",")
- For j = 0 To UBound(s1)
- arr(i, j) = s1(j)
- Next j
- Next i
- Cells(p, "a") = Replace(arr(5, 1), "'", "")
- Cells(p, "b") = Replace(Split(Cells(p, "a"), "-")(0), Mid(Split(Cells(p, "a"), "-")(0), 3, 5), "")
- Cells(p, "c") = Split(Cells(p, "a"), "-")(1)
- Cells(p, "G") = arr(3, 3)
- If arr(11, 7) = "Bef" Then
- Cells(p, "H") = "[Before]"
- Else
- Cells(p, "H") = "[After]"
- End If
- Cells(p, "I") = arr(11, 5)
- Cells(p, "J") = arr(11, 5)
- Cells(p, "K") = arr(20, 5)
- Cells(p, "R") = arr(21, 5)
- Cells(p, "S") = arr(22, 5)
- Cells(p, "T") = arr(23, 5)
- k = 20
- For i = 26 To 33
- For j = 1 To 3
- k = k + 1
- Cells(p, k) = arr(i, (j - 1) * 2 + 1)
- Next j
- Next i
- Next f
- End Sub
複製代碼 |
|