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

[µo°Ý] VBA TXT ¨Ì·Ó¬q¸¨¶}±Ò»Ý¨D

¦^´_ 10# Jason80Lo


If (T = "#" Or T = "$") And N = "" Then Set xR = xEnd(1, "M"): C = 0: N = "Y"
¡Ä·í¹J"#"©Î"$"¡A§Y¥H³Ì«á¦Cªº¢ÛÄ欰¶ñ¤J¸ê®Æªº°_©l®æ¡A
¡@¦]"#"»P"$"­Ó¼Æ¤£¤@©w¡A¥B®É¦³®ÉµL¡A¤S¦ì¸m¨S¦³¬J©w¶¶§Ç¡A
¡@©Ò¥H¡A¥u­n¹J¨ì²Ä¤@­Ó"#"©Î"$"¡A§Y¥HN="Y"ªí¥Ü¤w¨ú±o°_©l®æ¡A¨ä«áªº´Nºâ¬O²Ö­p­Ó¼Æ¡ã¡ã
¡@
¸ê®Æ­n¦³©T©w³W«h¡]¨Ì´£¨Ñªº¬O¤T¬q¦¡¡^¡A§_«hµ{¦¡µLªk¼gªº¡I

TOP

¦^´_ 11# ­ã´£³¡ªL
If (T = "#" Or T = "%") And N = "" Then Set xR = xEnd(1, "FZ"): C = 0: N = "Y"
¤£¦n·N«ä­ã¤j¡A§ÚªºTXTÀɳW«h³£¬O»P²Ä¤@­Ó¤@¼Ë¡A¥Ø«eªº°ÝÃD¬O¶}±Ò²Ä¤@­ÓTXTÀɱƦC³£OK¡A
¦ý²Ä¤@­Ó¥H«áªº¹J¨ì#¡B%ªº±Æ§Ç´NµLªk±qFZÀx¦s®æ¶ñ¤J¡C

TOP

¦^´_ 11# ­ã´£³¡ªL

20151115.rar (19.34 KB)
    ¦pªþÀɤå¦rÀÉ

TOP

¦^´_ 12# Jason80Lo


N = ""¡@'¦b³o¸Ì¥[¤J
Open xPath & xF For Input Access Read As #1


¦]²Ä¤@­Ó¤å¦rÀÉ°õ¦æ«á N = "Y"¡A
©Ò¥H¨C¦¸³£­n±N N ³]¦^ªÅ­È¡A¤~¤£·|³Q¿ù»~¤Þ¥Î¡I

TOP

¦^´_ 14# ­ã´£³¡ªL


    ­ã¤j §Ú±N§Aªº¤èªk®M¤J
    If (T = "#" Or T = "%") And N = "Open xPath & xF For Input Access Read As #1" Then Set xR = xEnd(1, "N"): C = 0: N = "Y"
¦ý¬OÅã¥Ü¥X¨Óªº±Æ¦C"#" ¨S¦³¨Ì·Ó§Ú­nªº±qNÄæ¦ì¶}©l¨Ì§Ç±Æ¦C¡A¦Ó¬Oª½±µ¨Ì§ÇÄæ¦ì±Æ¦C¤U¨Ó¡A½Ð°Ý¬O¤p§Ì­þ¸Ì¥´¿ù@@

TOP

¦^´_ 15# Jason80Lo


Sub TEST()
Dim xPath$, xF$, xS As Worksheet, xEnd As Range, xR As Range, TT, T, N$, C%
xPath = ThisWorkbook.Path & "\" '"C:\Users\j\Desktop\VBA TXT ¨Ì·Ó¬q¸¨¶}±Ò»Ý¨D\"
Set xS = ThisWorkbook.Sheets("¤u§@ªí1")
Do
¡@If xF = "" Then xF = Dir(xPath & "\*.txt") Else xF = Dir
¡@If xF = "" Then Exit Do
¡@If Not xS.[A:A].Find(xF, LookAT:=xlWhole) Is Nothing Then GoTo 101
¡@Set xEnd = xS.Cells(Rows.Count, 1).End(xlUp)(2)
¡@If xEnd.Row < 3 Then Set xEnd = xS.[A3]
¡@xEnd = xF
¡@
¡@N = ""¡@
¡@Open xPath & xF For Input Access Read As #1
¡@Do Until EOF(1)
¡@¡@¡@Line Input #1, T
¡@¡@¡@If T = "&" Then Set xR = xEnd(1, "B"): C = 0
¡@¡@¡@If T = "$" Then Set xR = xEnd(1, "BG"): C = 0
¡@¡@¡@If (T = "#" Or T = "%") And N = "" Then Set xR = xEnd(1, "FZ"): C = 0: N = "Y"
¡@¡@¡@If T = "@" Then Set xR = xEnd(1, "DX"): C = 0
¡@¡@¡@For Each TT In Split(T, " ")
¡@¡@¡@¡@¡@C = C + 1:   xR(1, C) = TT
¡@¡@¡@Next
¡@Loop
¡@Close #1
101: Loop
End Sub

TOP

¦^´_ 16# ­ã´£³¡ªL


    ·|¿ù·N¤F¡A¨þ¨þ
     Á¡Aª©¤j

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