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

[µo°Ý] EXCEL VBA XLSX TO TXT ªÅ¥Õ¦æ

¦^´_ 10# dou10801

·PÁ n7822123 ´£¨Ñ¥t¤@ºØ«ä¸ô,­«½Æ¦sÀÉ®É,¨t²Î·|¸ß°Ý,[¬O§_­n¨ú¥N],¦p«ö[§_]·|¤¤Â_,¦p¦ó¸Ñ¨M,·P®¦.

¨º´N±j¨îÂл\¡A¤£¸ß°Ý´N¦n¤F¡A²K¥[¤@¦æµ{¦¡§Y¥i

Sub Test1130()
Dim Arr, R&, C&
Application.DisplayAlerts = False   '­Y¤w¦³ÀɮסBª½±µÂл\¤£¸ß°Ý
myPath$ = ThisWorkbook.Path & "\"
xlsPath$ = myPath & "A001.xlsx"   'xlsÀɮרӷ½¸ô®|¡A½Ð¦Û¦æ³]©w(¹w³]¥»µ{¦¡Àɮ׸ô®|¤U)
txtPath$ = myPath & "A001.txt"     '¿é¥Xtxtªº¸ô®|&ÀɦW¡A½Ð¦Û¦æ³]©w(¹w³]¥»µ{¦¡Àɮ׸ô®|¤U)
With Workbooks.Open(xlsPath, , True).Sheets(1)
  Arr = .[A1].CurrentRegion
  For R = 1 To UBound(Arr)
    For C = 2 To UBound(Arr, 2)
      Arr(R, 1) = Arr(R, 1) & Arr(R, C)
    Next C
    Arr(R, 1) = Arr(R, 1) & String(21, " ")
  Next R
  .[A1].Resize(UBound(Arr), UBound(Arr, 2)) = Arr
  .Columns("B").Resize(, UBound(Arr, 2)).Delete
  .SaveAs txtPath, 42
  .Parent.Close True
End With
End Sub
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¦A¦¸½Ð±Ð«e½ú,ªþ¥ó¤¤¿ïa0063.xlsx,Âন.txt®É,¬°¦ó·|¦h²Ä¤@¦æ[½s¸¹],ÁÂÁÂ.

¿ïÀÉÂà¤å¦rÀÉ.rar (30.78 KB)

§ù¤p¥­

TOP

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-12-5 03:00 ½s¿è

¦^´_ 12# dou10801


¦]¬°§AªºxlsxÀÉ¡A¥»¨­´N¦³¼ÐÃD¦Cªü=.=

Arr °}¦C¤@¶}©l´N·|¨ú¨ì¼ÐÃD¦C¡A©Ò¥H§AªºFor°j°é¡AR§ï¦¨±q2¶}©l¤]¨S¦³¥Î

³Ì«á§â°}¦Cªº­È¶K¦^¥hÀx¦s®æÁÙ¬O¦³¼ÐÃD¦C~~

¥u­n¥[1¦æµ{¦¡§R±¼²Ä¤@¦C´N¦n¤F



      MES = UBound(Arr) - 1
      .[A1].Resize(UBound(Arr), UBound(Arr, 2)) = Arr
      .Columns("B").Resize(, UBound(Arr, 2)).Delete
      .Rows(1).Delete
      .SaveAs txtPath, 42
      .Parent.Close True
    End With
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¦^´_ 13# n7822123

«á¨Óµ¹ªºÀɮשM¤@¶}©lªº½d¥»,®Ú¥»¤£¤@¼Ë:@
¦h¤F¼ÐÃD¦C,ª÷ÃB¨ºÄæ¦r¼Æ¤£©T©w,¨º­Ó­n¥[21­ÓªÅ¥Õªº±ø¥ó,¬O¿ùªº§a?
ªÅ¥Õ¦r¼Æ¬O¨ä¹êÅܰʪº¤~¹ï?ÁÙ¬Oª÷ÃB¨ºÄæ­n¸É¦r¼Æ?

TOP

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-12-5 14:15 ½s¿è

¦^´_ 14# quickfixer


«á¨Óµ¹ªºÀɮשM¤@¶}©lªº½d¥»,®Ú¥»¤£¤@¼Ë

¨S¿ù!!!

¦h¤F¼ÐÃD¦C,ª÷ÃB¨ºÄæ¦r¼Æ¤£©T©w,¨º­Ó­n¥[21­ÓªÅ¥Õªº±ø¥ó,¬O¿ùªº§a?
ªÅ¥Õ¦r¼Æ¬O¨ä¹êÅܰʪº¤~¹ï?ÁÙ¬Oª÷ÃB¨ºÄæ­n¸É¦r¼Æ?   

³o­Ó§Ú¨S¥J²Ó¬Ý¥L«á­±ªº½d¥»©M¥L¸Éªºµ{¦¡¡A¬Ý¥L»Ý­n¤°»ò¦A¥h½T»{´N¦n

§Ú­Ì¥i¥HÀRÆ[¨äÅÜ
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¦^´_ 13# n7822123 ·PÁÂn7822123«e½ú«üÂI,¥[ .Rows(1).Delete,¤w¥i¥H¹B§@.·P®¦.
§ù¤p¥­

TOP

¦^´_ 14# quickfixer quickfixer«e½ú,©êºp²Ä¤G­Ó½d¥»¬O²Ä¤@­Ó½d¥»ªº©µ¦ù¥\¯à,²Ä¤G­Ó½d¥»¬O±N³Ì«á¤£¨¬ªÅ¶¡¸É¨ì81¦æ.Arr = .[A1].CurrentRegion
      For R = 1 To UBound(Arr)
          p1 = Len(Cells(R, MDS4))  '³ÆµùÄæªø«×.
          p2 = 29 - p1              '¸ÉªÅ¥Õªø«×
          mcs = mcs1 & Cells(R, MDS2) & Format(Cells(R, MDS3), "00000000000") & "00" & mcs2 & Cells(R, MDS4) & String(p2, " ")
          Arr(R, 1) = mcs
      Next R              ª÷ÃB¬OMSD3¸É0¨ì11¦ì,§Ú¨S»¡©ú²M·¡.
§ù¤p¥­

TOP

        ÀR«ä¦Û¦b : ­n§åµû§O¤H®É¡A¥ý·Q·Q¦Û¤v¬O§_§¹¬üµL¯Ê¡C
ªð¦^¦Cªí ¤W¤@¥DÃD