- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2017-12-27 14:55 ½s¿è
¦^´_ 1# takeshilin88
¸Õ¸Õ¬Ý- Option Explicit
- Dim WB As Workbook, AR(), D As Object
- Sub Main()
- Ex_yymm
- Ex_Copy
- End Sub
- Private Sub Ex_yymm()
- Dim i As Integer, YM As String
- Set D = CreateObject("SCRIPTING.DICTIONARY") '¦r¨åª«¥ó
- With Workbooks("A.XLSM").Sheets("¤ä²¼®M¦L")
- i = 6
- Do
- YM = Format(.Cells(i, "D"), "ee/mm")
- D(YM) = "=AND(YEAR(¨ì´Á¤é)=" & Format(.Cells(i, "D"), "YYYY") & ",MONTH(¨ì´Á¤é)=" & Format(.Cells(i, "D"), "mm") & ")" 'Format(.Cells(i, "D"), "ee/mm") 'YM : ¦r¨åª«¥óªºkeyÈ (Ū¨ú¤ë¥÷)
- i = i + 1
- Loop Until .Cells(i, "D") = ""
- i = Application.SheetsInNewWorkbook
- Application.SheetsInNewWorkbook = D.Count + 1
- Set WB = Workbooks.Add
- Application.SheetsInNewWorkbook = 1
- .Copy WB.Sheets(1)
- WB.Sheets(1).Rows("1:4").Delete
- WB.Sheets(1).Name = .Name
- End With
- AR = D.keys
- End Sub
- Private Sub Ex_Copy()
- Dim Sh As Worksheet, Rng As Range, i As Integer, xRow As Integer
- Set Sh = WB.Sheets(1)
- Set Rng = Sh.Cells(1, Columns.Count).Resize(2)
- Rng.Cells(1) = "AAA"
- For i = 0 To UBound(AR)
- Rng.Cells(2) = D(AR(i))
- Sh.Range("A:D").AdvancedFilter xlFilterCopy, Rng, WB.Sheets(i + 2).[A2]
- 'AdvancedFilter ¶i¶¥¿z¿ï , ¿z¿ï:½Æ»s ,¿z¿ï·Ç«h, ½Æ»s¨ìªº¦a¤è
- With WB.Sheets(i + 2)
- .Name = Replace(AR(i), "/", "_") & " ¨ì´Á"
- .[A1] = AR(i) & " ¨ì´Á:"
- .[d1] = Application.Evaluate("sum(" & .[c:c].Address(, , , 1, 1) & ")")
- .[d1].NumberFormatLocal = "#,##0_ "
- xRow = WB.Sheets(WB.Sheets.Count).Cells(Rows.Count, "a").End(xlUp).Row
- If xRow > 1 Then xRow = xRow + 1
- .Range("a1").CurrentRegion.Copy WB.Sheets(WB.Sheets.Count).Cells(xRow, "A")
- End With
- Next
- Rng.Clear
- With WB
- .Sheets(WB.Sheets.Count).Name = "¥Ø«e¤ä²¼ª¬ªp"
- .SaveAs "D:\B.XLSX" '¦sÀÉ
- End With
- End Sub
½Æ»s¥N½X |
|