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

[µo°Ý] ½Ð°Ý¦p¦ó§ó§ïVBªº³sµ²Àɮ׸ô®|

[µo°Ý] ½Ð°Ý¦p¦ó§ó§ïVBªº³sµ²Àɮ׸ô®|

³o­ÓVBA¥\¯à¬O±N¦h­ÓTXT¤º®e¥þ³¡·|¶°¨ì¦P¤@­ÓEXCEL¤¤
¦ý¬O³oµ{¦¡¥²¶·¸òTXT¦b¦P¤@­Ó¥Ø¿ý
§Ú¸ÕµÛ­×§ï¦¨§âµ{¦¡©ñ¦bC:\«ü©w¶×¶°D:\¤¤ªºTXT
¥i¬O³£¨S¦¨¥\
½Ð°Ý­n«ç»ò­×§ï¤~OK??
ÁÂÁÂ


Sub ¶×¤J¤å¦rÀÉ()
Dim xFile, uFile, uHead As Range, Jm&, Km&, X, xT, xL
Range("A:A").Clear '²M°£Â¶פJ¸ê®Æ
'-----------------------------------------------------
Application.ScreenUpdating = False
Do
    If xChk = 0 Then
       xFile = Dir(ThisWorkbook.Path & "\*.txt")
       If xFile = "" Then MsgBox "¡°§ä¤£¨ì TXT ÀɮסI¡@", 0 + 16: Exit Sub
       xChk = 1
    Else
       xFile = Dir
       If xFile = "" Then Exit Do
    End If
    '----------------------------------------------
    uFile = ThisWorkbook.Path & "\" & xFile
    Set uHead = Range("A65536").End(xlUp)
    If uHead <> "" Then Set uHead = uHead(3, 1)
    With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & uFile, Destination:=uHead)
         .AdjustColumnWidth = False
         .TextFileColumnDataTypes = Array(1)
         .Refresh BackgroundQuery:=False
         .Delete
    End With
    uHead.Interior.ColorIndex = 6
    '¨Cµ§²Ä¤@®æ¥[¡e¶À¦â¡f©³
NEXT_LINE:
Loop
'-------------------------------------------------------
Application.ScreenUpdating = True
MsgBox "¡ã¡ã¶×¤J§¹¦¨¡ã¡ã¡@"
End Sub


¶×¤J¤å¦rÀÉ.zip (8.72 KB)

¦^´_ 1# v60i
¥Î¸ê®Æ§¨¹ï¸Ü¤è¶ôµ²ªG¨ú¥NThisWorkbook.Path
  1. Sub ¶×¤J¤å¦rÀÉ()
  2. Dim xFile, uFile, uHead As Range, Jm&, Km&, X, xT, xL
  3. Range("A:A").Clear '²M°£Â¶פJ¸ê®Æ
  4. '-----------------------------------------------------
  5. With Application.FileDialog(msoFileDialogFolderPicker)
  6. .Show
  7. fd = .SelectedItems(1)
  8. End With

  9. Application.ScreenUpdating = False
  10. Do
  11.     If xChk = 0 Then
  12.        xFile = Dir(fd & "\*.txt")
  13.        If xFile = "" Then MsgBox "¡°§ä¤£¨ì TXT ÀɮסI¡@", 0 + 16: Exit Sub
  14.        xChk = 1
  15.     Else
  16.        xFile = Dir
  17.        If xFile = "" Then Exit Do
  18.     End If
  19.     '----------------------------------------------
  20.     uFile = fd & "\" & xFile
  21.     Set uHead = Range("A65536").End(xlUp)
  22.     If uHead <> "" Then Set uHead = uHead(3, 1)
  23.     With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & uFile, Destination:=uHead)
  24.          .AdjustColumnWidth = False
  25.          .TextFileColumnDataTypes = Array(1)
  26.          .Refresh BackgroundQuery:=False
  27.          .Delete
  28.     End With
  29.     uHead.Interior.ColorIndex = 6
  30.     '¨Cµ§²Ä¤@®æ¥[¡e¶À¦â¡f©³
  31. NEXT_LINE:
  32. Loop
  33. '-------------------------------------------------------
  34. Application.ScreenUpdating = True
  35. MsgBox "¡ã¡ã¶×¤J§¹¦¨¡ã¡ã¡@"
  36. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 2# Hsieh


    ¤j¤j ¦pªG§ÚÂI¥X¤F¿ï¾Ü¸ê®Æ§¨µe­±«á ¦pªG«ö¨ú®ø ·|¥X²{
°Å¶Kï01.jpg
ÂI¿ï°»¿ù
fd = .SelectedItems(1)
·|¤Ï¶À­C

TOP

¦^´_ 3# v60i
  1. With Application.FileDialog(msoFileDialogFolderPicker)
  2. If .Show = 0 Then Exit Sub   '§ï³o¸Ì
  3. fd = .SelectedItems(1)
  4. End With
½Æ»s¥N½X

TOP

¦^´_ 4# GBKEE


    ÁÂÁ¤j¤jªº­×¥¿

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD