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

[µo°Ý] ·j´M²Å¦X±ø¥óªº­q³æ¸¹½X

[µo°Ý] ·j´M²Å¦X±ø¥óªº­q³æ¸¹½X

¤j¤j¦n,

¦b"°£¥~¤u§@ªí"k1¦³¤@­Ó«ü©wªº­q³æ¸¹½X(¥¦·|¨Ì»Ý¨D¦ÓÅܰʸ¹½X)¬°¨Ì¾Ú,¥Î¨Ó·j´MBOM,½ÐÁÊ,»â®Æ...µ¥¤u§@ªí¤¤²Å¦X¦¹­q³æ¸¹½Xªº´N±N¥þ³¡®Æ¸¹¨Ì§Ç±Æ¦C¥X,½Ð°Ý¤°»ò¨ç¼Æ¥i¥H¹F¦¨³o­Ó­n¨D?
1) ¨ä¤¤BOM¤u§@ªíFÄæ®Æ¸¹¦³®É¸ê®Æ·|ªÅ¥Õ,©Ò¥H¬O¦³ªº¸Ü¦C¥X¦b°£¥~¤u§@ªíFÄæ¦ì,¨S¦³ªº¸Ü´NªÅ¥Õ,®Æ¸¹¤£¯à­«½Æ¥X²{,¨Ã¦bF1¼Ð¥ÜÁ`¦@¦³´Xµ§¸ê®Æ»â®Æ¤u§@ªí(¥[Á`µ§¼Æ­n¨Ó¦ÛBOM¤u§@ªí)
2) ½ÐÁÊ,»â®Æ2­Ó¤u§@ªíªº¸ê®Æ¥]§t¦UºØ­q³æ¸¹½X,©Ò¥H®Æ¸¹¬O¤£·|¨Ì­q³æ¶¶§Ç¥X²{ªº
3) ½ÐÁʤu§@ªíDÄæ²Å¦X­q³æ¸¹½Xªº¸Ü,´N±N®Æ¸¹¦C¦b°£¥~¤u§@ªíGÄæ¦ì,®Æ¸¹¤£¯à­«½Æ¥X²{,¨Ã¦bg1¼Ð¥ÜÁ`¦@¦³´Xµ§¸ê®Æ(¥[Á`µ§¼Æ­n¨Ó¦Û½ÐÁʤu§@ªí)
4) »â®Æ¤u§@ªíDÄæ²Å¦X­q³æ¸¹½Xªº¸Ü,´N±N®Æ¸¹¦C¦b°£¥~¤u§@ªíJÄæ¦ì,®Æ¸¹¤£¯à­«½Æ¥X²{,¨Ã¦bj1¼Ð¥ÜÁ`¦@¦³´Xµ§¸ê®Æ(¥[Á`µ§¼Æ­n¨Ó¦Û»â®Æ¤u§@ªí)
µù:­ì¥»¤u§@ªí¤¤¸ê®Æ´X¤dµ§,¦]¬°ÀɮפӤj§R°£«Ü¦h¸ê®Æ,©Ò¥H¥i¥H¬Ý¨ìªº­q³æ¸ê®Æ¨S¦³«Ü¦h.
®Æ¸¹.rar (43.68 KB)

§Ú§â°ÝÃD¦A¼g±o©ú½T¤@ÂI,
1        ·í"VBA³øªí«ü¥O.xlsm"H2Àx¦s®æ³]©w­È¬OM2®É
2        ¦b¨Ó·½¸ê®ÆÀÉ"®w¦s¸ê®Æªí.xlsx"ªºDÄæ,§ä´M²Ä¤@­Ó¥X²{ªºM2(¦bD11Äæ¦ì)
3        copy¨Ó·½¸ê®ÆÀÉ"®w¦s¸ê®Æªí.xlsx"ªº²Ä11¦C,±qA11:AAªº¸ê®Æ³Ì©³ºÝ (³o¤£¯à¥´¤W¤@­Ó¹ê»ÚªºÀx¦s®æ½d³ò,¦]¬°¸ê®Æ·|ÅÜ°Ê)
4        ¶K¨ì¥ØªºÀÉ"®w¦s.xlsx"ªºA11(¬Û¹ï¦ì¸m¬ODÄæ²Ä¤@µ§¥X²{ªºM2¦ì¸m:¦b²Ä11¦C)

½Ð°Ý¦³¤H·|¼g³o¼ËªºVBA¶Ü¡H   ¨ÌÅܼƷj´M¸ê®Æ.rar (298.83 KB)

TOP

¦^´_ 2# PJChen

¶K¤Wªº¦ì¸m¬O®w¦sÀɮתº¦ì¸m¡A­Y­ì¨Ó®w¦sªºµ§¼Æ¤£¦P¸Ó¦p¦ó³B²z?
­Yµ§¼Æ¬Û¦P´N·|ª½±µÂл\­ì¦³¸ê®Æ¡A³o¬O§Aªº»Ý¨D¶Ü?
­Yµ§¼Æ±Ð­û¸ê®Æ¦h¡A«h·|¼vÅT¤£¦P·Ç«hªº¸ê®Æ¡A³o¨Ç¸ò®w¦sÆ[©À¦n¹³³£¤£²Å¦X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 3# Hsieh

¤j¤j¦n,

§Ú§ìªº³øªí¤é´Á°Ï¶¡¥i¯à´N¬O·í¤ë¥÷ªº,ExcelÀɤ¤ªº¸ê®Æ·|²Ö¿n¤ñ¸û¦h¸ê®Æ,©Ò¥H§Ú¦bVBA³øªí«ü¥O.xlsm H2¤¤«ü©w¤@­Ó³æ¸¹¦WºÙ,¦Ó¤@­Ó³æ¸¹¥i¯à¦³«Ü¦hµ§,©Ò¥H§Ú­n«ü©w¥¦¥i¥H±q§ä¨ìªº²Ä¤@µ§¶}©l¶K¤W,³o¼Ë´N¤£·|»\±¼§Ú»Ý­nªº¸ê®Æ,¦P®É¤]¥i¥H§ó·s§Ú­nªº¸ê®Æ.

¥u¬O§Ú¤â¤W¥¿¦n¦³³o­Ó¸ê®Æ,©Ò¥H´N°½Ãi¥Î³o­ÓÀɨӸ߰Ý,¤£¹LÆ[©À¬O¬Û¦Pªº.

TOP

¦^´_ 4# PJChen

°Ñ¦Ò¬Ý¬Ý
  1. Sub copy_all()
  2. Dim ws() '¤w¸g¶}±Òµøµ¡
  3. books = Array("®w¦s¸ê®Æªí.xlsx", "®w¦s.xlsx") '±ý¶}±ÒÀÉ®×
  4. mypath = ThisWorkbook.Path '¦s©ñÀɮ׸ê®Æ§¨
  5. For Each w In Windows '¤w¸g¶}±Òµøµ¡
  6.    ReDim Preserve ws(s)
  7.    ws(s) = w.Caption
  8.    s = s + 1
  9. Next
  10. For Each b In books '´ú¸ÕÀɮ׬O§_¶}±Ò
  11.    If UBound(Filter(ws, b)) = -1 Then Workbooks.Open (mypath & "\" & b) 'ÀÉ®×¥¼¶}±Ò«h¶}±Ò
  12. Next
  13. x = ThisWorkbook.Sheets(1).[H2] '·Ç«h
  14. With Workbooks(books(0)) '®w¦s¸ê®Æªí.xlsx
  15.     Set a = .Sheets(1).Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
  16.     If a Is Nothing Then MsgBox "§ä¤£¨ì·Ç«h¦ì¸m": End
  17.     k = Application.CountIf(a.EntireColumn, x) '¦X¥G·Ç«h¦C¼Æ
  18.     Set Rng = .Sheets(1).Cells(a.Row, "B").Resize(k, 26) 'B:AAÄæ¸ê®Æ
  19.     With Workbooks(books(1)) '®w¦s.xlsx
  20.        k1 = Application.CountIf(.Sheets(1).Columns("D"), x) '¦X¥G·Ç«h¦C¼Æ
  21.        Set a = .Sheets(1).Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
  22.        If a Is Nothing Then Set a = .Sheets(1).Cells(.Sheets(1).Rows.Count, 4).End(xlUp).Offset(1) '­ì¸ê®Æ¤£¦s¦b·Ç«h¸ê®Æ
  23.        yn = MsgBox("­ì¸ê®Æ" & k1 & "¦C¡A·s¸ê®Æ" & k & "¦C¡A¬O§_½Æ»s?", vbYesNo)
  24.        If yn = 6 Then
  25.           a.Offset(, -2).Resize(k, 26).Value = Rng.Value '¼g¤J·s¸ê®Æ
  26.           MsgBox "¸ê®Æ¤w§ó·s"
  27.         Else
  28.           MsgBox "¸ê®Æ¥¼§ó·s", 48
  29.        End If
  30.     End With
  31. End With
  32. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 5# Hsieh

¤j¤j,

§Ú´ú¸Õ¤F´X¦¸,µo²{¤@¨Ç°ÝÃD,­n¦A³Â·Ð±z­×§ï¤U.

1. ¦b´ú¸Õªº®É­Ô,§Ú¬G·N§â"®w¦s.xlsx"ªº¸ê®Æ§R°£,¥u«O¯d¦Ü1000¦C.
2. "®w¦s¸ê®Æªí"¦@1059¦C(³£¨S¦³§R°£), ·í§Ú§â"VBA³øªí«ü¥O.xlsm" H2ªºÅܼƧאּM1®É,¥¦À³¸Ó­n±q"®w¦s¸ê®Æªí"ªºA1:AA1059½Æ»s¨ì"®w¦s.xlsx"ªºA1:AA1059¶Kº¡,¦ý¥¦¥u¸ß°Ý¦³9¦C·s¸ê®Æ¬O§_­n§ó·s.
3. ·í§Ú§â"®w¦s.xlsx"ªº¸ê®ÆAÄæ¸ê®Æ«O¯d10¦C,¨ä¾lA11¥H«á¬°ªÅ¥Õ®É¡A¥¦¤]µLªk¥¿±`§ó·s¸ê®Æ

P.S. ¤j¤j¼gªºµ{¦¡¦]¬°¤£¬O¥¨¶°¦¡ªº,§Ú¦³¬Ý¨S¦³À´,±z¥i§_À°§Úµù¸Ñ¦A§ó¸Ô²Ó¨Ç¡A¦]¬°³o­Óµ{¦¡,§Ú·|À³¥Î¨ì«Ü¦h¸ê®Æ¤W¡A¸Ô²Óªºµù¸Ñ¦³§U©ó§Ú¤é«áªº¤p­×§ï.  
ªþ¤W§Ú´ú¸ÕªºÀÉ®× ¨ÌÅܼƷj´M¸ê®Æ2.rar (298.47 KB)

¥ýÁÂÁ¤F.

TOP

¦^´_ 6# PJChen
  1. Sub copy_all()
  2. Dim ws() '¤w¸g¶}±Òµøµ¡
  3. books = Array("®w¦s¸ê®Æªí.xlsx", "®w¦s.xlsx") '±ý¶}±ÒÀÉ®×
  4. mypath = ThisWorkbook.Path '¦s©ñÀɮ׸ê®Æ§¨
  5. For Each w In Windows '¤w¸g¶}±Òµøµ¡
  6.    ReDim Preserve ws(s)
  7.    ws(s) = w.Caption
  8.    s = s + 1
  9. Next
  10. For Each b In books '´ú¸ÕÀɮ׬O§_¶}±Ò
  11.    If UBound(Filter(ws, b)) = -1 Then Workbooks.Open (mypath & "\" & b) 'ÀÉ®×¥¼¶}±Ò«h¶}±Ò
  12. Next
  13. x = ThisWorkbook.Sheets(1).[H2] '·Ç«h
  14. With Workbooks(books(0)).Sheets(1) '®w¦s¸ê®Æªí.xlsx
  15.     Set a = .Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
  16.     If a Is Nothing Then MsgBox "§ä¤£¨ì·Ç«h¦ì¸m": End
  17.     Set Rng = .Range(a.Offset(, -2), a.End(xlDown).Offset(, 23)) 'B:AAÄæ¸ê®Æ
  18.     MsgBox Rng.Address
  19.     With Workbooks(books(1)).Sheets(1) '®w¦s.xlsx
  20.        Set a = .Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
  21.        If a Is Nothing Then Set a = .Cells(.Rows.Count, 4).End(xlUp).Offset(1) '­ì¸ê®Æ¤£¦s¦b·Ç«h¸ê®Æ
  22.        .Range("A" & a.Row & ":AA" & .Rows.Count).ClearContents
  23.           a.Offset(, -2).Resize(Rng.Rows.Count, 26).Value = Rng.Value '¼g¤J·s¸ê®Æ
  24.           a.Offset(, -3).Resize(Rng.Rows.Count, 1) = Rng.Columns(5).Value '¼g¤JAÄæ½s¸¹
  25.           MsgBox "¸ê®Æ¤w§ó·s"
  26.     End With
  27. End With
  28. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 7# Hsieh

¤j¤j,
1) ¸g´ú¸Õ,¶K¸ê®Æªº®É­Ô,¥¦·|§âAAÄ檺¸ê®Æ¶K¨ìAÄæ,µM«á¨ä¥L¸ê®Æ¦V¥k²¾¤@­ÓÄæ¦ì....½Ð°Ý­n¦p¦ó­×¥¿?
2) ¦]¬°³o­Óµ{¦¡,§ÚÁÙ·|¨Ï¥Î¦b¨ä¥Lªº¤å¥ó¤W¡Abooks = Array("®w¦s¸ê®Æªí.xlsx", "®w¦s.xlsx"),¬O§_ÀɦW¤£¦P®É,§Ú¥u­n§ï¤£¦PÃC¦âªºÀɦW§Y¥i¡H¨ä¥LÀɦW¦pµ{¦¡¤¤ªºSheets(1)§Ú¤£¥Î°Ê¥¦,¬O¶Ü¡H
3) ·í§ÚªºÀɮצs©ñ¸ô®|¤£¦P®É,§Ú»Ý­n­×§ï¤°»ò¦a¤è¶Ü¡H
4) ¦ý¨C¥÷³øªíªº¶K¤W¦ì¸m¤£¦P,¦pªG§Ú­n¦Û¤v­×§ï¡A¥HVBA³øªí«ü¥O.xlsmªºVBA«ü¥O.sheet H2Àx¦s®æ¬°·j´M·Ç«h¥h·j´M¥ØªºÀÉCÄæ,¦ý¬O¶K¤W­n¦bBÄæ,§Ú­n«ç»ò­×§ï?

¤£¦n·N«ä,³Â·Ð§A¤F...

TOP

¦^´_ 7# Hsieh
¤j¤j,
§Ú­×§ï¤F¨Ç¤p¦a¤è,²{¦b¶K¤W®É¥¿±`¤F.
  1. Sub copy_all()
  2. Dim ws() '¤w¸g¶}±Òµøµ¡
  3. books = Array("®w¦s¸ê®Æªí.xlsx", "®w¦s.xlsx") '±ý¶}±ÒÀÉ®×
  4. mypath = ThisWorkbook.Path '¦s©ñÀɮ׸ê®Æ§¨
  5. For Each W In Windows '¤w¸g¶}±Òµøµ¡
  6.    ReDim Preserve ws(s)
  7.    ws(s) = W.Caption
  8.    s = s + 1
  9. Next
  10. For Each b In books '´ú¸ÕÀɮ׬O§_¶}±Ò
  11.    If UBound(Filter(ws, b)) = -1 Then Workbooks.Open (mypath & "\" & b) 'ÀÉ®×¥¼¶}±Ò«h¶}±Ò
  12. Next
  13. x = ThisWorkbook.Sheets(1).[H2] '·Ç«h
  14. With Workbooks(books(0)).Sheets(1) '®w¦s¸ê®Æªí.xlsx
  15.     Set a = .Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
  16.     If a Is Nothing Then MsgBox "§ä¤£¨ì·Ç«h¦ì¸m": End
  17.     Set Rng = .Range(a.Offset(, -3), a.End(xlDown).Offset(, 23)) 'B:AAÄæ¸ê®Æ
  18.     'MsgBox Rng.Address
  19.     With Workbooks(books(1)).Sheets(1) '®w¦s.xlsx
  20.        Set a = .Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
  21.        If a Is Nothing Then Set a = .Cells(.Rows.Count, 4).End(xlUp).Offset(1) '­ì¸ê®Æ¤£¦s¦b·Ç«h¸ê®Æ
  22.        .Range("A" & a.Row & ":AA" & .Rows.Count).ClearContents
  23.           a.Offset(, -3).Resize(Rng.Rows.Count, 27).Value = Rng.Value '¼g¤J·s¸ê®Æ
  24.           'a.Offset(, -3).Resize(Rng.Rows.Count, 1) = Rng.Columns(5).Value '¼g¤JAÄæ½s¸¹
  25.           MsgBox "¸ê®Æ¤w§ó·s"
  26.     End With
  27. End With
  28. End Sub
½Æ»s¥N½X

TOP

¦^´_ 7# Hsieh

§Ú¦Û¤v­×§ï¤Fµ{¦¡¦ý¨S¦³¶Kªº°Ê§@,½Ð°Ý
Row.Count­n¦p¦ó¼Æ¡HOffset(1)¤S¥Nªí¤°»ò¡H
ÁÙ¦³²Ä¤G¦æªºµ{¦¡­n«ç»ò¸ÑŪ¡H
  1. If a Is Nothing Then Set a = .Cells(.Rows.Count, 4).End(xlUp).Offset(1) '­ì¸ê®Æ¤£¦s¦b·Ç«h¸ê®Æ
  2.        .Range("A" & a.Row & ":AA" & .Rows.Count).ClearContents
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤H­nª¾ºÖ¡B±¤ºÖ¡B¦A³yºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD