- ©«¤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
|
¦^´_ 1# koala2099 - Option Explicit
- Sub Ex() '¶i¶¥¿z¿ï + ¦Û°Ê¿z¿ï
- Dim Rng As Range, xi As Integer
- Application.ScreenUpdating = False
- With ActiveSheet '§@¥Î¤¤ªº¤u§@ªí
- '¨Ï¥Î AdvancedFilter ¶i¶¥¿z¿ï ¿z¿ï¤£«´_ªº¸ê®Æ ¨ú±o¦³®ÆªºÜ®w------------
- '°Ñ¼Æ Action: =xlFilterCopy (½Æ»s¦b§Oªº½d³ò)
- '°Ñ¼Æ CriteriaRange (·Ç«h½d³ò) ':=.Cells(1, .Columns.Count - 1).Resize(2) ·Ç«h½d³ò¡C¦pªG¬Ù²¤¦¹¤Þ¼Æ«hµL·Ç«h¡C
- '·Ç«h½d³ò ªº±ø¥ó¬°ªÅ¥Õ¬°©Ò¦³¿z¿ïªº¸ê®Æ
- '°Ñ¼Æ CopyToRange ¿ï¾Ü©Êªº Variant¡C¦pªG Action ¬° xlFilterCopy¡A¦¹¤Þ¼Æ«ü©w³Q½Æ»s¦Cªº¥Ø¼Ð½d³ò¡C§_«h©¿²¤¦¹¤Þ¼Æ¡C
- '°Ñ¼Æ Unique ¿ï¾Ü©Êªº Variant¡CY¬° True¡A«h¶È¿z¿ï°ß¤@ªº°O¿ý¡FY¬° False¡A«h¿z¿ï¥X©Ò¦³²Å¦X·Ç«hªº°O¿ý¡C¹w³]Ȭ° False¡C
- .Cells(1, .Columns.Count - 1) = "aaa" '
- .Range("B:B").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Cells(1, .Columns.Count - 1).Resize(2), _
- CopyToRange:=.Cells(1, .Columns.Count), Unique:=True
- '------------------------------------------------------------------
- Set Rng = .Columns(.Columns.Count).SpecialCells(xlCellTypeConstants) 'Ü®w§Oªº½d³ò
- .AutoFilterMode = False '¨ú®ø ³o¤u§@ªíªº¦Û°Ê¿z¿ï
- For xi = 2 To Rng.Count 'Ü®wªº°j°é
- .[A1].AutoFilter Field:=2, Criteria1:=Rng(xi) '¦Û°Ê¿z¿ï ²Ä2Äæ ¤¤ «ü©w Ü®w
- .[A1].CurrentRegion.Copy '½Æ»s¦Û°Ê¿z¿ï¨ìªº¸ê®Æ
- With Workbooks.Add(1) '·s¶}¬¡¶Ã¯ ¤u§@ªí1±i
- .Sheets(1).Paste '²Ä1±i¤u§@ªí ¶K¤W¸ê®Æ
- .Sheets(1).Name = Rng(xi) '²Ä1±i¤u§@ªí ©R¦W:Ü®w§O
- .SaveAs ThisWorkbook.Path & "\" & Rng(xi) & ".xls" '·s¶}¬¡¶Ã¯ ¦sÀÉ
- .Close '·s¶}¬¡¶Ã¯ Ãö³¬
- End With
- Next
- .Cells(1, .Columns.Count - 1).Resize(, 2).EntireColumn.Clear '²M°£¶i¶¥¿z¿ïªº¸ê®Æ
- End With
- Application.ScreenUpdating = True
- End Sub
½Æ»s¥N½X |
|