¶×¥X¤u§@ªí¥X²{" °}¦C¯Á¤Þ¶W¥X½d³ò"°ÝÃD
- ©«¤l
- 176
- ¥DÃD
- 98
- ºëµØ
- 0
- ¿n¤À
- 279
- ÂI¦W
- 0
- §@·~¨t²Î
- window 7
- ³nÅ骩¥»
- office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-2-17
- ³Ì«áµn¿ý
- 2020-4-8
|
¶×¥X¤u§@ªí¥X²{" °}¦C¯Á¤Þ¶W¥X½d³ò"°ÝÃD
¦U¦ì°ª¤â½Ð«ü±Ð
ÀɮצWºÙ ¤u§@ªí¦WºÙ
file 1 101
file 1 aa.xls
file 1 102
file 2 103
file 2 104
file 2 bb.xls
¸ò¾ÚAÄæ¤ÎBÄæ¸ê®Æ±N¤u§@ªí¶×¥X
¦ÓAÄæ¦WºÙ¦P¼Ë¬O·sÀɮצWºÙ, ¶×¥X«áAÄæ¤u§@ªí¦b·sÀɮ׳̥ªÃä
BÄæ¦WºÙ¥i¯à¬O¤u§@ªí©ÎÀɮצWºÙ
¦pªGBÄæ¬O¤u§@ªí, ±N¤u§@ªí¶×¥X¦Ü·sÀÉ®×, ¦pªG¬OÀÉ®×(.xls§À), ¶}±ÒÀɮ׫á, ±NÀɮפºªº©Ò¦³¤u§@ªí¶×¥X
(YBÄ檺Àɮפ£¦s¦b, ¥X²{ĵ§i´£¥Ü)
(Àx¦s¶×¥XÀÉ®×®É, YÀɮפw¦s¦b, ¨ú¥N¦³ÀÉ®×)
¦]´¼ÃÑ©Ò, ¼g¤FÓÃþ¦üªºµ{¦¡,
¤£ª¾¦p¦ó³]©w«Å§i¤Îקï
¦ý·íµ{¦¡¥h¨ì
Sheets(Attfile).Copy before:=Workbooks(Exfile).Sheets(1)
¥X²{"°}¦C¯Á¤Þ¶W¥X½d³ò" ,
¦U¦ì°ª¤â¥i¥HÀ°¦£¶Ü
Sub export1()
'
On Error Resume Next
Dim REF As Object ' Àx¦sÀɮצWºÙ
Dim Exfile As String 'AÄæ¶×¥XÀɮצWºÙ
Dim Path_ExFile As String 'AÄæ¶×¥XÀɮצWºÙ³s¸ô®|
Dim Attfile As String 'BÄæ¶×¤J¤u§@ªí©ÎÀɮצW
Dim Path_Attfile As String 'BÄæ¶×¤JÀɮצWºÙ³s¸ô®|
Sheets("SUMMARY").Select
Range("A2").Select '¥ÑA2Àx¦s®æ¶}©l°õ¦æ
Set REF = ActiveCell
Do Until IsEmpty(REF.Value) ' °õ¦æµ{¦¡ª½¦ÜAÄæªÅ¥Õ¦æ¤~°±¤î°õ¦æ
'³]©w¦U¶µ¥N¼Æ©w¸q
Attfile = REF.Offset(0, 1) 'BÄæ¶×¤J¤u§@ªí©ÎÀɮצW
Exfile = REF.Value 'AÄæ¶×¥XÀɮצWºÙ Packing List
Path_ExFile = "C:\" & REF 'AÄæ¶×¥XÀɮצWºÙ³s¸ô®|
Path_Attfile = "C:\" & Attfile 'BÄæ¶×¤JÀɮצWºÙ³s¸ô®|
If REF <> REF.Offset(-1, 0) Then 'AÄæÀx¦s®æ»P¤W¤@¦æ¤£¦P (IF_0)
'·íAÄæÀx¦s®æ»P¤W¤@¦æ¤£¦P
Sheets(Exfile).Copy 'copy ¤u§@ªí¨Ã«Ø¥ß·sÀÉ®×
ActiveWorkbook.SaveAs Filename:=Path_ExFile '¸ò¾ÚAÄæÀɮצWºÙÀx¦sÀÉ®×
End If '(IF_0)
If Right(Attfile, 3) = "xls" Then 'ÀˬdBÄæ¬O§_ÀÉ®×(³Ì¥k¤å¦r¬O§_XLS) (IF 1)
'·íBÄæ¬OÀÉ®×
Err.Clear ' ²M°£error code
Workbooks.Open Filename:=Path_Attfile '¹Á¸Õ¶}±ÒÀÉ®× (IF_4)
Debug.Print Err.Number '©ó§Y®É¹BºâÅã¥Ü¿ù»~¥N¸¹,¥u§@½s¼gµ{¦¡Àˬd¥Î³~
If Err.Number = 0 Then 'YÀɮפ£¦s¦b¦s¦^¿ù»~¥N¸¹
'·íÀÉ®×¥X¤w¦s¦b
Workbooks(Attfile).Sheets(1).Copy before:=Workbooks(Exfile).Sheets(1)
Workbooks(Attfile).Close
Else '(IF_4)
'·íÀɮפ£¦s¦b , ¿ù»~¥N¸¹¤£µ¥©ó0®É, Åã¥Ü´£¥Ü°T®§
MsgBox "¶×¥XÀÉ®× " & Exfile & " ®É, ÀÉ®× " & Path_Attfile & " ¤£¦s¦b", vbExclamation + vbOKOnly, "attention" 'YÀɮפ£¦s¦b®ÉÅã¥ÜÀɮצWºÙ
End If '(IF_4)
ThisWorkbook.Activate 'ªð¦^export¬¡¶Ã¯
Else ' (IF 1)
'·íBÄæ¬O¤u§@ªí
ThisWorkbook.Activate 'ªð¦^export¬¡¶Ã¯
Sheets(Attfile).Copy before:=Workbooks(Exfile).Sheets(1) 'copy ¤u§@ªí¥h²{¦³ÀÉ®×
ThisWorkbook.Activate 'ªð¦^export¬¡¶Ã¯
End If '(IF 1)
'ÀˬdAÄæ¬O§_¤w§¹¦¨¶×¥XÀÉ®×
If REF <> REF.Offset(1, 0) Then 'AÄæÀx¦s®æ»P¤U¤@¦æ¤£¦P (IF_2)
Workbooks(Exfile).Save ' Àx¦s¤ÎÃö³¬ÀÉ®×
Workbooks(Exfile).Close
End If '(IF_2)
Set REF = REF.Offset(1, 0) ' ±NAÄæ¦ì¸m¦V¤U²¾¤@¦æ
Loop ' ªð¦^Do unit Ä~Äò°õ¦æµ{¦¡
End Sub |
|
|
|
|
|
|