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

[µo°Ý] VBAµ{¦¡ ¶}±Ò¤@­Ó¬Û¦PÀɦW¤£¦PÀÉ®×

¦^´_ 3# èªÎ¯Ì¦Ï

©Î¬O»¡·í¶}±Ò¬Û¦P¦WºÙ®É¡A¨Ï¥L¤¤Â_°j°é¶i¦æ¤U¤@­ÓRunªº¥¨¶°¡A¤£ª¾¬O§_¥i¦æ??

TOP

¦^´_ 2# samwang


¤£¦n·N«ä»¡©úªº¤£²M·¡¡A¥Ø«e¬O·Q¶}¨â­Ó¬Û¦PÀɮצý¤£¦P°ÆÀɦWCSV»PTXT¡AµM«á¦A±NTXT¸Ì­±ªº¸ê®Æ½Æ»s¦bCSVÀÉ¡AµM«á¥t¦sÀɮצb¶i¦æ½ü°j¡C
¥Ø«e¸ê®Æ³B²z¨ì¥t¦sÀɮפw³B²z¦n¡A¦ý¥d¦b²Ä¤@Ãö¶}±ÒÀɮתº³¡¤À¡A­ì¦]¬O·í¸ê®Æ§¨¸Ì¦³²Ä¤G­ÓexcelÀÉ¥H¤W®É·|¦P®É¤@°_¶}¤U¥h

¥H¤U¬O©Ò¦³ªºµ{¦¡½X:
Sub A¶}±ÒSPI_TXT()

    Dim lrow As Long
    Dim mFile As String
    Dim Filename As String
   
    If Len(Dir(ThisWorkbook.Path & "\TEST", vbDirectory)) = 0 Then
    MkDir ThisWorkbook.Path & "\TEST"
    End If
   
    mFile = Dir(ThisWorkbook.Path & "\csvÀÉ\" & "*.csv")
    Do While mFile <> ""
    Workbooks.Open Filename:=ThisWorkbook.Path & "\csvÀÉ\" & mFile
    mFile = Dir()
   
    mFile = Dir(ThisWorkbook.Path & "\TXTÀÉ\" & "*.txt")
    Do While mFile <> ""
    Workbooks.Open Filename:=ThisWorkbook.Path & "\TXTÀÉ\" & mFile
    mFile = Dir()
   
    Loop
    Loop
   
    Run "TXT½Æ»s¦ÜCSV"
   
End Sub

Sub TXT½Æ»s¦ÜCSV()

    Workbooks(2).Activate
    Workbooks(2).Worksheets.Add Before:=Sheets(Sheets.Count)
    '¬¡­¶2(CSV)·s¼W¤u§@ªí
   
    For i = 1 To Sheets.Count
    Sheets(i).Name = "Sheet" & i
    Next
   
    Workbooks(3).Activate
    Columns("A:A").Select
    Selection.Copy
    Workbooks(2).Activate
    Sheets("Sheet1").Select
    ActiveSheet.Paste
    '±N¬¡­¶3(TXT)¸ê®Æ½Æ»s¦Ü¬¡­¶2(CSV)
   
    Application.CutCopyMode = False
    Workbooks(3).Close
   
    Run "¥t¦sTESTÀÉ"
   
End Sub
Sub ¥t¦sTESTÀÉ()

    Filename = ActiveWorkbook.Name
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\TEST\" & Filename, _
    FileFormat:=xlCSV, CreateBackup:=False
    Application.DisplayAlerts = True
    Application.WindowState = xlNormal
    '¥t¦sTEST
   
    ActiveWindow.Close SaveChanges:=False
   
End Sub

ªþ¥óÀÉ®×¥i¥H¸Õ¶]¡A¦A³Â·ÐÀ°§Ú¬Ý¬Ý....ÁÂÁÂ

Desktop.zip (20.45 KB)

¸Õ¶]¥¨¶°

TOP

¦^´_ 1# èªÎ¯Ì¦Ï


¬Ý¤£¤ÓÀ´±zªº»Ý¨D¬°¦ó?¥i¥H¤W¶Çªþ¥ó©M»Ý¨Dµ²ªG¡AÁÂÁÂ
±N¸ê®Æ³B²z«á¥t¦s¤@­Ó·sÀÉ®×>> ¸ê®Æ«ç»ò³B²z?

TOP

        ÀR«ä¦Û¦b : ¡i»X½ªªº¦Û¥Ñ¡j¤H±`¦b¤°»ò³£¥i¥H¦Û¥Ñ¦Û¦bªº®É­Ô¡A«o³Q³oºØÀH¤ß©Ò±ýªº¦Û¥Ñ»X½ª¡AµêÂY®É¥ú¦Ó²@µLıª¾¡C
ªð¦^¦Cªí ¤W¤@¥DÃD