- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 62
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2025-3-13
               
|
¦^´_ 4# PJChen
°Ñ¦Ò¬Ý¬Ý- Sub copy_all()
- Dim ws() '¤w¸g¶}±Òµøµ¡
- books = Array("®w¦s¸ê®Æªí.xlsx", "®w¦s.xlsx") '±ý¶}±ÒÀÉ®×
- mypath = ThisWorkbook.Path '¦s©ñÀɮ׸ê®Æ§¨
- For Each w In Windows '¤w¸g¶}±Òµøµ¡
- ReDim Preserve ws(s)
- ws(s) = w.Caption
- s = s + 1
- Next
- For Each b In books '´ú¸ÕÀɮ׬O§_¶}±Ò
- If UBound(Filter(ws, b)) = -1 Then Workbooks.Open (mypath & "\" & b) 'ÀÉ®×¥¼¶}±Ò«h¶}±Ò
- Next
- x = ThisWorkbook.Sheets(1).[H2] '·Ç«h
- With Workbooks(books(0)) '®w¦s¸ê®Æªí.xlsx
- Set a = .Sheets(1).Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
- If a Is Nothing Then MsgBox "§ä¤£¨ì·Ç«h¦ì¸m": End
- k = Application.CountIf(a.EntireColumn, x) '¦X¥G·Ç«h¦C¼Æ
- Set Rng = .Sheets(1).Cells(a.Row, "B").Resize(k, 26) 'B:AAÄæ¸ê®Æ
- With Workbooks(books(1)) '®w¦s.xlsx
- k1 = Application.CountIf(.Sheets(1).Columns("D"), x) '¦X¥G·Ç«h¦C¼Æ
- Set a = .Sheets(1).Columns("D").Find(x, lookat:=xlWhole) '§ä·Ç«h¦ì¸m
- If a Is Nothing Then Set a = .Sheets(1).Cells(.Sheets(1).Rows.Count, 4).End(xlUp).Offset(1) 'ì¸ê®Æ¤£¦s¦b·Ç«h¸ê®Æ
- yn = MsgBox("ì¸ê®Æ" & k1 & "¦C¡A·s¸ê®Æ" & k & "¦C¡A¬O§_½Æ»s?", vbYesNo)
- If yn = 6 Then
- a.Offset(, -2).Resize(k, 26).Value = Rng.Value '¼g¤J·s¸ê®Æ
- MsgBox "¸ê®Æ¤w§ó·s"
- Else
- MsgBox "¸ê®Æ¥¼§ó·s", 48
- End If
- End With
- End With
- End Sub
½Æ»s¥N½X |
|