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

[µo°Ý] vba¶}±Ò¨Ã§ì¨ú«ü©w¸ê®Æ§¨¤ºÃöÁä¦rÀÉ®×&¬¡­¶¦WºÙ¸ê®Æ

¥»©«³Ì«á¥Ñ Hsieh ©ó 2018-3-6 17:20 ½s¿è

¦^´_ 10# msmplay
¸Õ¸Õ¬Ý
  1. Sub ex()
  2. Dim xlPath$
  3. xlPath = ThisWorkbook.Path
  4. Set fd = CreateObject("Scripting.Dictionary")
  5. fa = Array("list", "CCMOP_NAME", "CCMOP", "¹w¬ùªí³æ")
  6. sh = Array("list³øªí", "µL¸ê®Æ", "µL¸ê®Æ2", "¦³¸ê®Æ", "¦³¸ê®Æ2", "¹w¬ùªí³æ")
  7. an = Array(1, 1, 2, 1, 2, 4)
  8. For i = 0 To UBound(fa)
  9. f = Dir(xlPath & "\" & fa(i) & "*.xls")
  10. Do Until f = ""
  11. If fd.exists(f) = False Then
  12. fd(f) = f
  13.    With Workbooks.Open(xlPath & "\" & f)
  14.      If i = 0 Then
  15.         ar = Array(1)
  16.         ElseIf i = 1 Or i = 2 Then
  17.         ar = Array(1, 2)
  18.         Else
  19.         ar = Array(4)
  20.      End If
  21.      For j = 0 To UBound(ar)
  22.        With .Sheets(ar(j))
  23.        If k = 0 Or k = 5 Then Rng = "A1" Else Rng = "B1"
  24.           .Range("A1").CurrentRegion.Copy ThisWorkbook.Sheets(sh(k)).Range(Rng)
  25.        End With
  26.        k = k + 1
  27.      Next
  28.       .Close 0
  29.    End With
  30. End If
  31. f = Dir
  32. Loop
  33. Next
  34. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 11# Hsieh


    H¤j~~~~­º¥ý«D±`«D±`«D±`·PÁ§A¼ö¤ßÀ°¦£³á~~~~~~~¤£¹L´ú¸Õµ²ªG¬°¡G
ÀÉ1¡ylist*.xls¡zªºSheets(1)­n¶×¤J¬¡­¶¡ulist³øªí¡vªºA1¡G¦¨¥\¶×¤J
ÀÉ2¡yCCMOPQ*.xls¡zªºSheets(1)¸òSheets(2)­n¶×¤J¬¡­¶¡u¦³¸ê®Æ¡vªºB1¸ò¬¡­¶¡u¦³¸ê®Æ2¡vªºB1¡GSheets(1)¦¨¥\¶×¤J¡u¦³¸ê®Æ¡vªºB1¡ASheets(2)¥¼¶×¤J¦ý¶×¤J¦¨Sheets(1)¨ì¡u¦³¸ê®Æ2¡vªºB1
ÀÉ3¡yCCMOP_NAME*.xls¡zªºSheets(1)¸òSheets(2)­n¶×¤J¬¡­¶¡uµL¸ê®Æ¡vªºB1¸ò¬¡­¶¡uµL¸ê®Æ2¡vªºB1¡GSheets(1)¦¨¥\¶×¤J¡uµL¸ê®Æ¡vªºB1¡ASheets(2)¥¼¶×¤J¦ý¶×¤J¦¨Sheets(1)¨ì¡uµL¸ê®Æ2¡vªºB1
ÀÉ4¡y¹w¬ùªí³æ*.xls¡zªºSheets(4)­n¶×¤J¬¡­¶¡u¹w¬ùªí³æ¡vªºA1¡G¥¼¶×¤J

¥i¥H¦A½Ð§AÀ°¦£¬Ý¬Ý¶Ü~~~~~~
*¦v¤k¤@ªTµL»~*

TOP

¦^´_ 11# Hsieh


   H¤j~~~~´ú¸Õ¦¨¥\¤F³á!!!«D±`·PÁÂ~~~~~~~
*¦v¤k¤@ªTµL»~*

TOP

        ÀR«ä¦Û¦b : ¡i¬°µ½Ävª§¡j¤H¥Í­n¬°µ½Ävª§¡A¤À¬í¥²ª§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD