ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¥Hado¤è¦¡¡A±NcsvÀÉ©ñ¶i°}¦C¤¤¥X¿ù¡H(·í¤¤¦³­^¤å¦r¥À)

¦^´_ 2# joey0415
´£¨Ñ§A°Ñ¦Ò¡G
  1. Sub CSV_Import()
  2.     Dim ws As Worksheet, strFile As String

  3.     Sheets("ÀɮצWºÙ").Select
  4.     Cells.Clear
  5.    
  6.     Set ws = ActiveSheet 'set to current worksheet name
  7.     '  strFile = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Please select text file...")
  8.     '  §A¤]¥i¥Hª½±µ«ü©wÀɮצWºÙ
  9.     strFile = ThisWorkbook.Path & "\9962.csv"

  10.     With ws.QueryTables.Add(Connection:="TEXT;" & strFile, Destination:=ws.Range("A1"))
  11.          .TextFileParseType = xlDelimited
  12.          .TextFileCommaDelimiter = True
  13.          .Refresh
  14.     End With
  15. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# joey0415
  1. Sub CSV_Import()
  2.     Dim ws As Worksheet, strFile As String, i As Long
  3.     Dim arr
  4.    
  5.     Sheets("ÀɮצWºÙ").Select
  6.     Cells.Clear
  7.    
  8.     Set ws = ActiveSheet 'set to current worksheet name
  9.     '  strFile = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Please select text file...")
  10.     '  §A¤]¥i¥Hª½±µ«ü©wÀɮצWºÙ
  11.     strFile = ThisWorkbook.Path & "\9962.csv"

  12.     With ws.QueryTables.Add(Connection:="TEXT;" & strFile, Destination:=ws.Range("A1"))
  13.          .TextFileParseType = xlDelimited
  14.          .TextFileCommaDelimiter = True
  15.          .Refresh
  16.     End With
  17.    
  18.     arr = Range("A1:E" & Range("A" & Rows.Count).End(xlUp).Row)
  19.     For i = LBound(arr, 2) To UBound(arr, 1)
  20.         Debug.Print arr(i, 1) & ","; arr(i, 2) & ", " & arr(i, 3) & ", " & arr(i, 4) & ", " & arr(i, 5) & ";"
  21.     Next i
  22. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤Hªº¤ß¦a¬O¤@²¥¥Ð¡A¤g¦a¨S¦³¼½¤U¦nºØ¤l¡A¤]ªø¤£¥X¦nªºªG¹ê¡C -
ªð¦^¦Cªí ¤W¤@¥DÃD