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

[µo°Ý] ¿ï¾ÜÀÉ®×Âন¤å¦rÀÉ°ÝÃD.

[µo°Ý] ¿ï¾ÜÀÉ®×Âন¤å¦rÀÉ°ÝÃD.

1.¿ïÀÉ[21.XLSX]Âন21.TXT¥i¥H,¬°¦ó¿ïÀÉ[22.XLSX]Âন22.TXT¤£¦æ,°ÝÃD¦b¨º¸Ì?
2.¥i§_[«ü©w¤u§@ªí]:
MP1=Range(¡§B7¡¨)
'With Workbooks.Open(xlsPath, , True).Sheets(MP1)  '¦p¦ó«ü©w¤u§@ªí=>¤£¦æ
With Workbooks.Open(xlsPath, , True).Sheets(1)         '¥i¦æ.

aaa.rar (39.4 KB)

§ù¤p¥­

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-11-3 09:18 ½s¿è

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


    ÁÂÁ«e½ú«ü¾É,¥H¤UApplication.Text()¾Ç²ß¤ß±o¦p¤U,½Ð«e½ú¦A«ü¾É

Option Explicit
'³Ì²z·QÁÙ¬O¥ÎAPPLICATION.TEXT(¼Æ¦r©Î¤å¦r,"¥¿;­t;0;¤å¦r")
'VBA¤¤©I¥s¤u§@ªí¤¤ªºTEXT¨ç¼Æ

Sub TEST_Text_1°Ï¬q()
MsgBox Application.Text(10, "0000")
MsgBox Application.Text(-1.2, "0000")
MsgBox Application.Text(0, "0000")
End Sub

Sub TEST_Text_2°Ï¬q()
MsgBox Application.Text(0, "000;-0.00")
MsgBox Application.Text(10, "000;-0.00")
MsgBox Application.Text(9999, "000;-0.00")
MsgBox Application.Text(-1, "000;-0.00")
MsgBox Application.Text(-10.1111, "000;-0.00")
End Sub

Sub TEST_Text_3°Ï¬q()
MsgBox Application.Text(0, "000;-0.00;0")
MsgBox Application.Text(10, "000;-0.00;0")
MsgBox Application.Text(9999, "000;-0.00;0")
MsgBox Application.Text(-1, "000;-0.00;0")
MsgBox Application.Text(-10.1111, "000;-0.00;0")
MsgBox Application.Text(-10.1111, "000;­Ë¦©¤F;0")
End Sub
Sub TEST_Text_4°Ï¬q()
MsgBox Application.Text(0, "0000;-0.00;¹s;¿é¤J¿ù»~")
MsgBox Application.Text(10, "0000;-0.00;¹s;¿é¤J¿ù»~")
MsgBox Application.Text(9999, "0000;-0.00;¹s;¿é¤J¿ù»~")
MsgBox Application.Text(-1, "0000;-0.00;¹s;¿é¤J¿ù»~")
MsgBox Application.Text(-10.1111, "0000;-0.00;¹s;¿é¤J¿ù»~")
End Sub

Sub TEST_Text_4°Ï¬q_0()
MsgBox Application.Text(0, "0000;-0.00;;¿é¤J¿ù»~")
MsgBox Application.Text(0, "0000;-0.00;0;¿é¤J¿ù»~")
MsgBox Application.Text(0, "0000;-0.00;#;¿é¤J¿ù»~")
MsgBox Application.Text(0, "0000;-0.00;¨ú®ø;¿é¤J¿ù»~")
MsgBox Application.Text("0o", "0000;-0.00;¹s;¿é¤J¿ù»~")
'¡ôAPPLICATION.TEXT(¼Æ¦r©Î¤å¦r,"¥¿­È®æ¦¡;­t­È®æ¦¡;·Q­nªº¤å¦r®æ¦¡1;·Q­nªº¤å¦r®æ¦¡2")
'¦pªG ¼Æ¦r©Î¤å¦r¬O¥¿¼Æ ,¥O¥H¥¿­È®æ¦¡¦^¶Ç
'§_«h¦pªG ¼Æ¦r©Î¤å¦r¬O­t¼Æ,¥O­t­È®æ¦¡¦^¶Ç
'§_«h¦pªG ¼Æ¦r©Î¤å¦r¬O0,¥O¥H·Q­nªº¤å¦r®æ¦¡1¦^¶Ç
'§_«h¦pªG«e­±3­Ó±ø¥ó³£¤£¦¨¥ß,¥O¥H·Q­nªº¤å¦r®æ¦¡2¦^¶Ç

End Sub

==============================================
¦bÀx¦s®æ®æ¦¡À³¥Îªº¤è¦¡¦p¤U:
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-11-3 07:27 ½s¿è

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


    ÁÂÁ«e½ú,½Ð«e½ú¦A«ü¾É
1. «á¾Ç¾Ç¨ìªº¬O ;; ¨â­Ó¤À¸¹¥Nªíªº¬O¸õ¹L­t¼Æªº§PÂ_,ª½±µ§PÂ_¬O¤£¬O0
2.«á¾Ç¹ï # ²Å¸¹¦bFormat()¸Ìªº·N¸q¤£¤F¸Ñ
¨Ò¦p:Format(Arr(i, Cn(1)), "00000000000;;""""") »P
Format(Arr(i, Cn(1)), "00000000000;;#")
³o¨â­Ó¦³¦ó¤£¦P?

'==========================================
¾Ç²ß¸É¥R:
(#)¼Æ¦r¹w¯d¦ì¸m¡C ·|Åã¥Ü¼Æ¦r©Î¤£Åã¥Ü¥ô¦ó¶µ¥Ø¡C ¦pªG¹Bºâ¦¡¦³¼Æ¦r¦ì¦b®æ¦¡¦r¦ê¤¤¥X²{ # ªº¦ì¸m¡A
«hÅã¥Ü¸Ó¦r¤¸¡F§_«h¦b¸Ó¦ì¸m¤£Åã¥Ü¥ô¦ó¶µ¥Ø¡C ¦¹²Å¸¹ªº§@¥Î´N¹³ 0 ¼Æ¦r¹w¯d¦ì¸m¡A¤£¦P¤§³B¦b©ó¡A
¦pªG¦b®æ¦¡¹Bºâ¦¡¤¤¡A¼Æ¦r¦b¤p¼Æ¤À¹j²Å¸¹¥ô¤@Ã䪺¦ì¼Æ¡A»P # ¦r¤¸ªº¦ì¼Æ¬Û¦P©Î§ó¤Ö¡A
«h¤£·|Åã¥Ü«e¸m¹s©Î¦æ§À¹s¡C
https://learn.microsoft.com/zh-t ... ic-for-applications

ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 23# Andy2483

¥u¹ï"¥¿¼Æ"¤Î"¹s­È"°µ³W½d, ¹s­È¬°"ªÅ", ¸Õ¸ÕÀx¦s®æ³]¬°"#", ¦A¿é¤J0
­Y¤]­n±N"­t¼Æ"Åܦ¨ªÅ¦r¦ê
MsgBox Format(-1500, "00000000000;"""";#")
¦ý¹ï²Ä¥|°Ñ¼Æ"¤å¦r"ªºÅã¥Ü¤è¦¡µLªkÅܧó,
³Ì²z·QÁÙ¬O¥ÎAPPLICATION.TEXT(¼Æ¦r©Î¤å¦r, "¥¿;­t;0;¤å¦r")

TOP

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


    ½Ð±Ð«e½ú
1.Format(Arr(i, Cn(1)), "00000000000;;#")¬O«ü  [¥¿¼Æ;­t¼Æ;0;¥»¤å]
1.1.¦pªGArr(i, Cn(1))­È¬O¥¿¼Æ´N¥H11¦ì¼Æ§e²{(¤£¨¬³¡¤À¥Î0¶ñ¥R¦b¥ª°¼)
1.2.¦pªGArr(i, Cn(1))­È¬O­t¼Æ´N¥HªÅ®æ§e²{
¬O³o¼Ëªº·N¸q¶Ü?

2.½Ð±Ð«e½ú³o³Ì«áªº  ;# ¬O¤°»ò·N«ä?

ÁÂÁ«e½ú
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-11-3 07:20 ½s¿è

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


    ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É
¥H¤U¬OÃjÀ´ªº¤ß±oµù¸Ñ,½Ð«e½ú¦A«ü¾É

Sub Test_a1()
Dim xFile$, T1$, T2$, BN$, SN$, P$, PP$, Sx%, Cn, Arr, i&
'¡ô«Å§iÅܼÆ:(xFile,T1,T2,BN,SN,P,PP)¬O¦r¦êÅܼÆ,Sx¬Oµu¾ã¼ÆÅܼÆ,
'(Cn,Arr)¬O³q¥Î«¬ÅܼÆ,i¬Oªø¾ã¼ÆÅܼÆ

ChDir ThisWorkbook.Path
'¡ôChDir "D:\"  '«ü©w¶}±ÒÀɮתº¸ô®|
xFile = Application.GetOpenFilename("ExcelÀÉ,*.XLS*")
'¡ô¥OxFile³o¦r¦êÅܼƬO Åã¥Ü¼Ð·Çªº [¶}±ÒÂÂÀÉ] ¹ï¸Ü¤è¶ô¡A±q¨Ï¥ÎªÌ¨ú±oÀɮתº¦WºÙ
If xFile = "False" Then Exit Sub
'¡ô¦pªGxFileÅܼƬO¦r¦ê"False",¥Nªí¨S¦³¿ï¨úÀÉ®×,µ²§ôµ{§Ç°õ¦æ
T1 = [b1] & Mid([b2], 2, 6) & [b3] & [b4]
'¡ô¥Omcs1³o¦r¦êÅܼƬO [b1]Àx¦s®æ­È,³s±µ[b2]Àx¦s®æ­È¨ú²Ä2¦r¤¸¶}©lªº6¦r¤¸¦r¦ê,
'¦A³s±µ[b3]Àx¦s®æ­È,³Ì«á³s±µ[b4]Àx¦s®æ­È,²Õ¦X¦¨ªº¦r¦ê (¤å¦r¦ê«e½X)

T2 = [b5]
'¡ô¥OT2³o¦r¦êÅܼƬO[b5]Àx¦s®æ­È (¦s´£´Ú¥N¸¹)
Sx = Val([b7])
'¡ô¥OSx³o¦r¦êÅܼƬO [b7]Àx¦s®æ­ÈÂà¤Æªº¾ã¼Æ­È («ü©w²Ä?±i¤u§@ªí(¨Ì¥ª¦Ó¥k¶¶§Ç))
Cn = Split([b6], ",")
'¡ô¥OCn³o³q¥Î«¬ÅܼƬO [b6]Àx¦s®æ¥H ³r¸¹¤À³Î¦¨ªº¤@ºû°}¦C («ü©wÄæ¦ì)
'---------------------------------

On Error Resume Next
'¡ô¥Oµ{§Ç°õ¦æ¤£°»¿ù
With GetObject(xFile)
'¡ô¥H¤U¬OÃö©ó¥HxFileÅܼƥÎGetObject¨ç¦¡ ¦^¶Çª«¥ó(¬¡­¶Ã¯)ªºµ{§Ç
'ÁÂÁ «e½ú«ü¾É³o¨ç¦¡ªº¥Îªk
'°õ¦æ¨ì³o¸Ì¨Ã¨S¦³¬Ý¨ì¶}±Ò¬¡­¶Ã¯,«Ü¯«©_!«á¨Ó¬d¬Ý¨ì¬¡­¶Ã¯µøµ¡³QÁôÂð_¨Ó¤F


'¦pªG¸Ó¬¡­¶Ã¯­ì¥»´N³Q¶}±Ò·|ª½±µ«ü¦V¦¹¬¡­¶Ã¯,¤£·|¦A­«·s¶}±Ò¤@¦¸
https://learn.microsoft.com/zh-t ... /getobject-function
     BN = Split(.Name, ".")(0)
     '¡ô¥OBN³o¦r¦êÅܼƬO ¬¡­¶Ã¯ÀɦW(¥h°£°ÆÀɦW)
     '(¥h°£°ÆÀɦW¤èªk:¥H"."²Å¸¹¤À³Î¬¡­¶Ã¯¦WºÙ,¨ú0¯Á¤Þ¸¹°}¦C­È)

     SN = .Sheets(Sx).Name
     '¡ô¥OSN³o¦r¦êÅܼƬO¬¡­¶Ã¯¸Ì²ÄSxÅܼƯÁ¤Þ¸¹¤u§@ªí¦WºÙ
     Arr = Range(.Sheets(Sx).[g1], .Sheets(Sx).UsedRange) '¸ê®Æ½d³ò(§tGÄæ)
     '¡ô¥OArr³o³q¥Î«¬ÅܼƬO¤Gºû°}¦C,¥H¤w¨Ï¥ÎÀx¦s®æ(§tGÄæ)½d³òÀx¦s®æ­È±a¤J
     .Close 0
     '¡ô¥O¬¡­¶Ã¯Ãö³¬(¤£Àx¦s)
End With
On Error GoTo 0
'¡ô¥Oµ{§Ç«ì´_°»¿ù
If SN = "" Then MsgBox "«ü©w¤u§@ªí¤£¦s¦b!  ": Exit Sub
'¡ô¦pªGSNÅܼƬO ªÅªº!´N¸õ¥X´£µøµ¡~~~ ,µ²§ôµ{§Ç°õ¦æ
'----------------------------------

For i = 2 To UBound(Arr)
'¡ô³]¶¶°j°é!i±q2 ¨ìArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
    P = T1 & Arr(i, Cn(0))
    '¡ô¥OP³o¦r¦êÅܼƬO T1ÅܼƳs±µ i°j°é¦C(0¯Á¤Þ¸¹Cn°}¦C­È)ÄæArr°}¦C­È
    P = P & Format(Arr(i, Cn(1)), "00000000000;;#") & "00" & T2
    '¡ô¥OPÅܼƦA³s±µ i°j°é¦C(1¯Á¤Þ¸¹Cn°}¦C­È)ÄæArr°}¦C­È¥HFormat¨ç¦¡¦^¶Ç¦r¦ê,
    '¦A³s±µ "00",Äò³s±µT2ÅܼÆ
    '³o;;#¤À°Ï¬q²{¦bÁÙ¤£¯à²z¸Ñ,»Ý­n§ó¦h¾Ç²ß

    https://learn.microsoft.com/zh-t ... ic-for-applications
    P = P & Left(Arr(i, Cn(2)) & String(29, " "), 29)
    '¡ô¥OPÅܼƦA³s±µ 29­Ó¦r¤¸ªº¦r¦ê:
    'i°j°é¦C(2¯Á¤Þ¸¹Cn°}¦C­È)ÄæArr°}¦C­È ³s±µ29­ÓªÅ¥Õ¦r¤¸,©Ò²Õ¦¨ªº·s¦r¦ê,¨ú¥ª°¼29­Ó¦r¤¸

    If Len(P) = 80 Then PP = PP & IIf(PP = "", "", vbCrLf) & P
    '¡ô¦pªGPÅܼƦr¤¸¼Æ¬O80!´N¥OPP³o¦r¦êÅܼƲּW¥[¦r¦ê(Âk¦ì¦r¤¸´«¦æ²Õ¦X)¶¡¹j
    '¤å¦rÀÉ(.Txt)ÀɻݭnvbCrLf = CHR(13)+CHR(10) ¤~·|´«¦æ

    https://learn.microsoft.com/zh-t ... ellaneous-constants
i01: Next i
If PP = "" Then MsgBox "«ü©w¤u§@ªíµL²Å¦X¸ê®Æ!  ": Exit Sub
'¡ô¦pªGPPÅܼƬOªÅªº!´N¸õ¥X´£µøµ¡~~~ ,µ²§ôµ{§Ç°õ¦æ
'----------------------------------

xFile = ThisWorkbook.Path & "\" & BN & "-Sheets(" & Sx & ").TXT"
Open xFile For Output As #1  'OutputÂл\¸ê®Æ
'¡ô¥H¶¶§Ç¿é¤J¼Ò¦¡¶}±Ò ÀÉ®×
https://learn.microsoft.com/en-u ... help/open-statement
Print #1, PP
'¡ô±NÅã¥Ü®æ¦¡¤Æ¸ê®Æ Âл\¸ê®Æ¼g¤JÀÉ®×
https://learn.microsoft.com/zh-t ... help/printstatement
Close #1
'¡ôÃö³¬ÀÉ®×
MsgBox "¤å¦rÀɤw«Ø¥ß¡G" & xFile
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 20# ­ã´£³¡ªL
·PÁÂ:­ã´£³¡ªL,«ü¾É.¥N½Xµ¹ªì¾ÇªÌ§ó²M·¡¾Ç²ß,·P®¦.
§ù¤p¥­

TOP

°Ñ¦ÒÀÉ//
´CÅéÂà±b¤å¦rÀÉ.rar (22.52 KB)

TOP

ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
¥H¤U¤ß±oµù¸Ñ,½Ð¦U¦ì«e½ú«ü±Ð

Option Explicit
Sub «ö¶s1_Click()
Application.DisplayAlerts = False
'¡ô¥O°õ¦æ¨ì¬O§_Àx¦s¨ú¥NÂÂÀÉ®É,¤£¸õ¥X¸ß°Ýµ¡,ª½±µ¨ú¥NÀx¦s
Dim MyFile, Arr, Q, Brr$(), R&, Sc%, p2%, MDS$(2 To 4), mcs1$, mcs2$, Nm$, myPath$
'¡ô«Å§iÅܼÆ:(MyFile,Arr,Q)¬O³q¥Î«¬ÅܼÆ,Brr¬O°}¦C(°}¦C­È¬°¦r¦ê),R¬Oªø¾ã¼Æ,
'(Sc,p2)¬Oµu¾ã¼Æ,MDS¬O¤@ºû°}¦C(¯Á¤Þ¸¹2~4),(mcs1, mcs2,Nm,myPath)¬O¦r¦êÅܼÆ

MyFile = Application.GetOpenFilename("ExcelÀÉ,*.XLS*")
'¡ô¥OMyFile³o³q¥Î«¬ÅܼƬO Åã¥Ü¼Ð·Çªº [¶}±ÒÂÂÀÉ] ¹ï¸Ü¤è¶ô¡A±q¨Ï¥ÎªÌ¨ú±oÀɮתº¦WºÙ
https://learn.microsoft.com/zh-t ... ion.getopenfilename
If MyFile = False Then Exit Sub
'¡ô¦pªGMyFileÅܼƬOÅÞ¿è­È False,¥Nªí¨S¦³¿ï¨úÀÉ®×,µ²§ôµ{§Ç°õ¦æ
Q = Split([B6], ",")
'¡ô¥OQ³o³q¥Î«¬ÅܼƬO[B6]Àx¦s®æ¥H ³r¸¹¤À³Î¦¨ªº¤@ºû°}¦C
myPath = ThisWorkbook.Path & "\"
'¡ô¥OmyPath³o¦r¦êÅܼƬO ¥»¬¡­¶Ã¯©Ò¦bªº¸ô®|³s±µ "\"©Ò²Õ¦¨ªº¦r¦ê
mcs1 = [B1] & Mid([B2], 2, 6) & [B3] & [B4]
'¡ô¥Omcs1³o¦r¦êÅܼƬO [B1]Àx¦s®æ­È,³s±µ[B2]Àx¦s®æ­È¨ú²Ä2¦r¤¸¶}©lªº6¦r¤¸¦r¦ê,
'¦A³s±µ[B3]Àx¦s®æ­È,³Ì«á³s±µ[B4]Àx¦s®æ­È,²Õ¦X¦¨ªº¦r¦ê

mcs2 = [B5]: Sc = Val([B7])
'¡ô¥Omcs2³o¦r¦êÅܼƬO [B5]Àx¦s®æ­È¦r¦ê
'¥OSc³oµu¾ã¼Æ¬O [B7]Àx¦s®æ­ÈÂà¤Æªº¾ã¼Æ­È

If Sc <= 0 Then MsgBox "[B7]Àx¦s®æ¿é¤J¿ù»~": Exit Sub
'¡ô¦pªGScÅܼƤp©ó©Îµ¥©ó0!,´N¸õ¥X´£¥Üµ¡~~~,µ²§ôµ{§Ç°õ¦æ
With Workbooks.Open(MyFile, , True)
'¡ô¥H¤U¬OÃö©ó µL±K½X/°ßŪ/¶}±ÒMyFileÅÜ¼Æ ÂÂÀɪº¬ÛÃöµ{§Ç
   Nm = .Name
   '¡ô¥ONm³o¦r¦êÅܼƬO ³o¶}±ÒÀɮצW¦r¦r¦ê
   If Sc > .Worksheets.Count Then MsgBox Nm & " ¬¡­¶Ã¯¨S¦³²Ä" & Sc & " ­Óªí": .Close 0: Exit Sub
   '¡ô¦pªGScÅܼƤj©ó¦¹ÂÂÀɤu§@ªí¼Æ¶q!´N¸õ¥X´£µøµ¡~~~,Ãö³¬ÀÉ®×(¤£Àx¦s),µ²§ôµ{§Ç°õ¦æ
   With .Sheets(Sc)
   '¡ô¥H¤U¬OÃö©ó¦¹ÂÂÀɪº²Ä ScÅܼƭӤu§@ªíªº¬ÛÃöµ{§Ç
      If Not .AutoFilter Is Nothing Then If .FilterMode = True Then .ShowAllData
      '¡ô¦pªG¦³¿z¿ï¥\¯à!´N§PÂ_¦pªG¬O¿z¿ïª¬ºA!¥O²M°£¿z¿ï
      Arr = Range(.[G1], .[A65536].End(3))
      '¡ô¥OArr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥H¸Óªíªº[G2]¨ìAÄæ³Ì«á¦³¤º®eªºÀx¦s®æ,
      '¦¹½d³òÀx¦s®æ­È±a¤J°}¦C¤¤

   End With
   .Close 0
   '¡ô¥O¸ÓÂÂÀÉÃö³¬(¤£Àx¦s)
End With
If UBound(Arr) = 1 Then MsgBox Nm & " ¬¡­¶Ã¯²Ä" & Sc & " ­Óªí¨S¦³¸ê®Æ": Exit Sub
'¡ô¦pªGArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹¬O 1!´N¸õ¥X´£µøµ¡~~~,µ²§ôµ{§Ç°õ¦æ
ReDim Brr(1 To UBound(Arr) - 1, 1 To 1)
'¡ô«Å§iBrr°}¦CÁa¦V½d³ò±q¯Á¤Þ¸¹1 ¨ìArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹-1,¾î¦V½d³ò±q1~1¯Á¤Þ¸¹
For R = 2 To UBound(Arr)
'¡ô³]¶¶°j°é!¥ORÅܼƱq2 ¨ìArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
   If Arr(R, 3) <> "" Then
   '¡ô¦pªGR°j°é¦C²Ä3ÄæArr°}¦C­È¤£¬OªÅ¦r¤¸?
      p2 = 29 - Len(Arr(R, Val(Q(2))))
      '¡ô¥Op2³oµu¾ã¼ÆÅܼƬO 29-(°j°é°}¦C­Èªº¦r¤¸¼Æ)
      '°j°é°}¦C­È:(R°j°é¦C,2¯Á¤Þ¸¹Q°}¦C­ÈÂର¼Æ­ÈªºÄ渹)Arr°}¦C­È

      MDS(2) = Arr(R, Val(Q(0)))
      '¡ô¥O2¯Á¤Þ¸¹MDS°}¦C­È¬O (R°j°é¯Á¤Þ¦C,0¯Á¤Þ¸¹Q°}¦C­ÈÂର¼Æ­Èªº¯Á¤ÞÄ渹)Arr°}¦C­È
      MDS(3) = Format(Arr(R, Val(Q(1))), "00000000000")
      '¡ô¥O3¯Á¤Þ¸¹MDS°}¦C­È¬O (R°j°é¯Á¤Þ¦C,1¯Á¤Þ¸¹Q°}¦C­ÈÂର¼Æ­Èªº¯Á¤ÞÄ渹)Arr°}¦C­È,
      '¦A±N¦¹­ÈÂà¤Æ¬° "00000000000"®æ¦¡ªº¦r¦ê

      MDS(4) = Arr(R, Val(Q(2)))
      '¡ô¥O4¯Á¤Þ¸¹MDS°}¦C­È¬O (R°j°é¯Á¤Þ¦C,2¯Á¤Þ¸¹Q°}¦C­ÈÂର¼Æ­Èªº¯Á¤ÞÄ渹)Arr°}¦C­È
      Brr(R - 1, 1) = mcs1 & MDS(2) & MDS(3) & "00" & mcs2 & MDS(4) & String(p2, " ")
      '¡ô¥O(R°j°é-1)¦C1ÄæBrr°}¦C­È¬O ±µÄò¦h­Ó¦r¦ê²Õ¦¨ªº¦r¦ê
      'String(p2, " "):¬Op2­ÓªÅ¥Õ¦r¤¸ªº¦r¦ê

   End If
Next R
Workbooks.Add
'¡ô¥O·s¼W¤@­Ó¬¡­¶Ã¯
[A1].Resize(UBound(Arr) - 1, 1) = Brr
'¡ô¥O[A1]Àx¦s®æÂX®i¦V¤U(Arr°}¦CÁa¦V³Ì¤j¯Á¤Þ¸¹-1)¦Cªº½d³òÀx¦s®æ­È¥HBrr°}¦C­È±a¤J
Nm = StrReverse(Mid(StrReverse(Nm), InStr(StrReverse(Nm), ".") + 1))
'¡ô¥ONmÅܼƦr¦ê¤ÏÂà«á ¨ú"."«á(¤£§t)ªº©Ò¦³¦r¤¸,¦A¤ÏÂà¦^¨Ó
ActiveWorkbook.SaveAs myPath & Nm & ".TXT", 42
'¡ô¥OÀx¦s¬° ¤å¦r¦rÀÉ(Unicode ¤å¦r)
https://learn.microsoft.com/zh-t ... /excel.xlfileformat
ActiveWindow.Close
'¡ô¥O¦¹µøµ¡¬¡­¶Ã¯ Ãö³¬
ThisWorkbook.Activate
'¡ô¿E¬¡¥»ÀÉ
MsgBox "²£¥Í´CÅéÀÉ:" & myPath & Nm & ".TXT"
'¡ô¸õ¥X´£¥Üµ¡ ~~~
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 17# Andy2483
¾Ç¨ì¥t¤@ºØ¤è¦¡,·P¿E¤£ºÉ.
§ù¤p¥­

TOP

        ÀR«ä¦Û¦b : ¨ü¤HÂI¤ô¤§®¦¡A¶··í´é¬u¥H³ø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD