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

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

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

­ìTXT¶}±Ò«á¥u¯à¨Ì·ÓÀɮפºTXTÀɤ@¦¸¶}±Ò¡A¦p²Ä3¦C©Ò²£¥Íªºµ²ªG
¥Ø«e»Ý¨D¡G&¡B%¡B$ ¬°¦U¤@­Ó¬q¸¨¡A¬q¸¨®æ¼Æ¬°©T©wªº¡AÀɮ׶}±Ò«á¨Ì·Ó­Ó¬q¸¨ªº¯S§O²Å¸¹¥h¤ÀÃþ¡A¦p²Ä4¦C©Ò²£¥Íªºµ²ªG


½Ð¦U¦ì°ª¤âÀ°¦£¡A«ô°U

VBA TXT ¨Ì·Ó¬q¸¨¶}±Ò»Ý¨D.rar (19.33 KB)

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


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

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

¦^´_ 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

¦^´_ 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

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

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

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

¦^´_ 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

¥»©«³Ì«á¥Ñ Jason80Lo ©ó 2015-11-8 18:30 ½s¿è

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


¡@¡@If (T = "#" Or T = "$") And N = "" Then Set xR = xEnd(1, "M"): C = 0: N = "Y"
­ã¤j½Ð°Ý³o¦æªº·N«ä¡AxEnd(1, "M")¸Ì­±ªº1¤°»ò·N«ä¡H
¤p§Ì¸Õ¥t¤T­ÓTXTÀÉ¡A¦P®É¶}±Ò«á¥u¦³²Ä¤@­Ó¯à°÷¶¶§Q¨Ì·ÓÀx¦s®æ½s±Æ(¦p¤U¹Ï)
If (T = "#" Or T = "%") And N = "" Then Set xR = xEnd(1, "FZ"): C = 0: N = "Y"

123.png

TOP

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


    ÁÂÁ ­ã¤j ¤p§Ì ¬ã¨s¬ã¨s

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD