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

[µo°Ý] ¦p¦ó±NTEXTÂন¦Û­qªºEXCELÀÉ

[µo°Ý] ¦p¦ó±NTEXTÂন¦Û­qªºEXCELÀÉ

½Ð°Ý¦U¦ì«e½ú¡G
¦p¤U¦Cªþ¥ó¡A¦p¦ó±N"¤å¦r¤å¥ó.txt"Âন"¤å¥ó.xls"¤¤ªº¼Ë¦¡¡H

¸ê®Æ§¨.zip (2.21 KB)

ÁٽЦU¦ì«e½ú«ü±Ð¡C

¦^´_ 1# wsx24680

TOP

¦^´_ 2# GBKEE


GBKEE«e½ú¡G
¤£¦n·N«ä¡K¥i¯à¬O§Úªí¹F¤W¦³°ÝÃD¡A§Úªº·N«ä¬O¯à°÷Åܦ¨¹³"¤å¥ó.xls"¤¤ªº±Æ¦C¤è¦¡¡A
¨Ã¤£¥u¬O³æ¯Âªº¥Îexcel¨Ó¥´¶}txtÀÉ¡F¦Ó¬O¥´¶}txtÀÉ«á¯à°÷±N¸Ì­±ªº¸ê®Æ±Æ¦C¦¨"¤å¥ó.xls"¤¤ªº¼Ë¤l¡A
©Ò¥Hªþ¥ó¤¤"¤å¥ó.xls"¬Oºâ¬Oµª®×¡A¬O±NtxtÀÉÂà´««áªºµ²ªG¡C

·PÁÂGBKEE«e½ú«üÂI¡A¥i±¤¸ò§Ú·Q­n¹F¦¨ªºµ²ªG¤£¤@¼Ë¡C

TOP

¦^´_ 3# wsx24680
  1. Sub Ex()
  2.     Dim MyString, C%, R%, Ar
  3.     C = 2: R = 1
  4.     Open "D:\TEST\¤å¦r¤å¥ó.TXT" For Input As #1    ' ¶}±Ò¿é¤JÀɮסC
  5.   Do While Not EOF(1)    ' °õ¦æ°j°éª½¨ìÀɧÀ¬°¤î¡C
  6.         Input #1, MyString ',±N¸ê®ÆŪ¤JMyNumberÅܼƤ¤¡C
  7.             If InStr(MyString, "=") Then
  8.                 Ar = Split(MyString, Chr(9))
  9.                 Cells(R, C) = Ar(0)
  10.                 Cells(R, C + 1) = Split(Ar(1), "=")(0)
  11.                 Cells(R, C + 2) = "="
  12.                 Cells(R, C + 3) = Split(Ar(1), "=")(1)
  13.                 R = R + 1
  14.                 If R >= 20 Then R = 1: C = C + 6
  15.             End If
  16.     Loop
  17.     Close #1    ' Ãö³¬ÀɮסC
  18. End Sub
½Æ»s¥N½X

TOP

½Ð°Ý¤@¤UCells(R, C) = Ar(0)  ¬O¤°»ò·N«ä¡A¦]¬°§Ú¨ÌGBKEE«e½ú©Ò§iª¾¤§¥¨¶°¶i¦æ´ú¸Õ«á¡A
¥X²{¶¥¬q°õ¦æ¿ù»~'1004'¡A???

TOP

¦^´_ 5# q88007


    µ{¦¡½X¦³­×§ï¶Ü?  ¦p¦³½Ðªþ¤W

TOP

¦^´_ 4# GBKEE

GBKEEª©¤j¡G
¤Q¤À©êºp¡A¤p§Ì­è­è¤~ª`·N¨ìªþ¿ùÀɮפF¡A¹ï¤£°_¡A
¤§«eªþ¤Wªº¬O¦³­×§ï¹Lªº¤º®e¡A­è­è´ú¸Õ®É¤~µo²{¡A
­ì©lªºTEXT¤¤ªº¤º®e¦pªþ¥ó¡C
¸ê®Æ§¨.zip (290 Bytes)

ÁÙ¦³´XÂI·Q½Ð±Ð¤@¤U¡A
1.Àɸô®|¥i¥H¥Î¿ïªº¶Ü¡H¹³¶}±ÒÂÂÀɨº¼Ë¡K
2.If R >= 20 Then R = 1: C = C + 6¡A¦pªG¸ê®Æªø«×¤£¤@©w¡A
¦ý¥Î------¨Ó§PÂ_ªº¸Ü¬O§ï¦¨
If InStr(MyString, "----") Then R = 1: C = C + 6¡A³o¼Ë¶Ü¡H

¥t¥~­è­è¤p§Ì¦³·Q¸ÕµÛ­×§ïµ{¦¡¡A¦ý¤£ª¾¬°¦ó§ì¤£¨ì"="¸ò«á­±ªº­È¡A
²Ä¤@¦¸MyString§ì¨ì"3"«á¨Ó"AAA-AA"¡B"11"¡B«á¨Ó´NÅܧì¨ì"22"¤F¸õ¹L¤F"11"«á­±ªº"=10"
¤£ª¾¬°¦ó¡HÁٽЪ©¤j¸Ñ´b¡H

¦A¦¸·PÁª©¤jªºÀ°¦£

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2010-6-18 08:26 ½s¿è

¦^´_ 7# wsx24680
  1. Sub Ex()
  2. Dim Ar(), Mystr$, a$, s&, k%, fs$
  3. Cells = ""
  4. fs = Application.GetOpenFilename("Text Files (*.txt), *.txt")
  5. If fs = "False" Then MsgBox "½Ð¿ï¾Ü¤å¦rÀÉ": Exit Sub
  6. k = 2
  7. Open fs For Input As #1
  8. Do While Not EOF(1)
  9.     Line Input #1, Mystr
  10.     If Mystr <> "" And Not IsDate(Mystr) Then
  11.       If InStr(Mystr, "=") = 0 And InStr(Mystr, "---") = 0 Then
  12.       a = Mystr
  13.       ElseIf InStr(Mystr, "=") > 0 Then
  14.       ReDim Preserve Ar(s)
  15.       Ar(s) = Array(a, Split(Mystr, "=")(0), "=", Split(Mystr, "=")(1))
  16.       s = s + 1
  17.       ElseIf InStr(Mystr, "---") > 0 Then
  18.       Cells(1, k).Resize(s, 4).Value = Application.Transpose(Application.Transpose(Ar))
  19.       k = k + 6: s = 0: Erase Ar
  20.       End If
  21.     End If
  22. Loop
  23. If s > 0 Then Cells(1, k).Resize(s, 4).Value = Application.Transpose(Application.Transpose(Ar))
  24. Close #1
  25. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2010-6-18 07:22 ½s¿è

¦^´_ 8# Hsieh
Hsieh ªO¥D §A«Å§ifs$ ¬°¦r¦ê«¬ºA  
If fs = False Then MsgBox "½Ð¿ï¾Ü¤å¦rÀÉ": Exit  Sub  
·|²£¥Í [«¬ºA¤£²Å] ªº¿ù»~ ­×¥¿¦pµ{¦¡½X
  1. Dim Ar(), Mystr$, a$, s&, k%, fs$
  2. Cells = ""
  3. fs = Application.GetOpenFilename("Text Files (*.txt), *.txt")
  4. If fs = "False" Then MsgBox "½Ð¿ï¾Ü¤å¦rÀÉ": Exit Sub
½Æ»s¥N½X
¦^´_ 7# wsx24680
½Ð°Ñ¦Ò¥t¤@­Ó¶}±ÒÀɮתº¼gªk
  1. Sub Ex()
  2.     Dim Ar(), Mystr$, a$, s&, k%, fs$
  3.     With Application.FileDialog(msoFileDialogOpen)
  4.         .Title = "´M§ä¤å¦rÀÉ"
  5.         .AllowMultiSelect = False   '¥u·Ç³\¿ï¨ú¤@­ÓÀÉ®×
  6.         .ButtonName = "¶}±ÒTxtÀÉ"
  7.         .InitialFileName = "d:\test\*.txt"  '³]©wÀɮשҦbªº¸ê®Æ§¨ ¤Î°ÆÀɦW
  8.         If .Show = False Then
  9.             MsgBox "½Ð¿ï¾Ü¤å¦rÀÉ": Exit Sub
  10.         Else
  11.             fs = .SelectedItems(1)
  12.         End If
  13. End With
  14. k = 2
  15. Open fs For Input As #1
  16. Do While Not EOF(1)
  17. '
  18. '
  19. Loop
  20. If s > 0 Then Cells(1, k).Resize(s, 4).Value = Application.Transpose(Application.Transpose(Ar))
  21. Close #1
  22. End Sub
½Æ»s¥N½X

TOP

¦^´_ 9# GBKEE


   
·PÁÂGBKEEª©¤j¤ÎHsiehª©¤jªºÀ°¦£¡A
¥Ø«eµ{¦¡°õ¦æ¨S¦³°ÝÃD¡Aµ²ªG¤]¥¿½T¡C
¤º®e§ÚÁÙ­n¬ã¨s¤@¤U¡A
­Y¦³µo²{¨ä¥¦°ÝÃD¡A¦A¨Ó¦V¦U¦ì½Ð±Ð¡C

TOP

        ÀR«ä¦Û¦b : ­ì½Ì§O¤H´N¬Oµ½«Ý¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD