- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 24# ¤d·u´M
³o¬O§Úªº§@·~¤ß±o³ø§i¡A©Î³\¯àÀ°§U§A¶i¤@¨B¤§¤F¸Ñ¡A
±N¥¦¶K¤W´£¨Ñ°Ñ¦Ò¡A¦b¦¹½gijÃD¤¤§Úı±oã¤jªº¸ÑÃD
¥Ó½×«D±`¤§´Î¡A³æ¤M¤Á¤Jª½±µ¤F·í¡A¤@´ª§Y¦¨¡C
¦b¦¹¥ç·PÁ 㴣³¡ªLª©¤j ªº¤£§[«ü¾É¡C- ' ¿z¿ïªk¡I¡I¡I ã´£³¡ªL
- ' ¨Ï¥Î¦¹¤èªk "·JÁ`ªí" ¤§ªì©l¤º®e¤£¶·¥ý¦æ±Æ§Ç (Sorting)¡A¥ç§Y¦b«O«ùì©lª¬ªp¤Uª½±µ¶i¦æ¿z¿ï³B¸Ì
- Sub ex2()
- Dim xArea As Range, i&, T$, TT$, Sht As Worksheet
-
- With Sheets("·JÁ`ªí")
- .Select
- Set xArea = .Range([B1], Cells(Rows.Count, "B").End(xlUp)(1, 4))
- ' xArea : Range/Range : xArea.Address = "$B$1:$E$7" : String
- End With
-
- For i = 2 To xArea.Rows.Count ' xArea.Rows.Count : 7 : Long, xArea.DataSeries : True : Variant/Boolean
- T = xArea(i, 1): Set Sht = Nothing ' i = 2 : Long
- ' -------------------------------------------------------------------------
- ' ¬°Æ[¹î InStr(TT & "/", "/" & T & "/") ¥H¤Î TT = TT & "/" & T ªº³B²z¤è¦¡¡A
- ' ¯S±N "·JÁ`ªí" ¤º®e¤§¶¶§Ç¨Æ¥ý¹w§@½Õ¾ã¦p¤U¡A¥H¤è«K°»´ú TT ¹Lµ{¤¤§êºtªº¨¤¦â¡C
- ' -------------------------------------------------------------------------
- ' 2(i) : xArea(i, 1) = "A" : xArea(i, 2) = "»¿¼" : xArea(i, 3) = 10 : xArea(i, 4) = 100 : Variant/Object/Range
- ' 3(i) : xArea(i, 1) = "B" : xArea(i, 2) = "«C´Ô" : xArea(i, 3) = 50 : xArea(i, 4) = 500 : Variant/Object/Range
- ' 4(i) : xArea(i, 1) = "A" : xArea(i, 2) = "¸²µå" : xArea(i, 3) = 30 : xArea(i, 4) = 300 : Variant/Object/Range
- ' 5(i) : xArea(i, 1) = "B" : xArea(i, 2) = "»ñ±ù" : xArea(i, 3) = 40 : xArea(i, 4) = 400 : Variant/Object/Range
- ' 6(i) : xArea(i, 1) = "C" : xArea(i, 2) = "ªÝ¼Ö" : xArea(i, 3) = 60 : xArea(i, 4) = 600 : Variant/Object/Range
- ' 7(i) : xArea(i, 1) = "A" : xArea(i, 2) = "Ä«ªG" : xArea(i, 3) = 20 : xArea(i, 4) = 200 : Variant/Object/Range
-
- If T = "" Or InStr(TT & "/", "/" & T & "/") Then GoTo 101
- ' ----------------------------------------------------------------------------------------------
- ' 2(i) : TT & "/" = "/" : "/" & T & "/" = "/A/" : InStr(TT & "/", "/" & T & "/") = 0 : Long
- ' 3(i) : TT & "/" = "/A" : "/" & T & "/" = "/B/" : InStr(TT & "/", "/" & T & "/") = 0 : Long
- ' 4(i) : TT & "/" = "/A/B" : "/" & T & "/" = "/A/" : InStr(TT & "/", "/" & T & "/") = 1 : Long
- ' 5(i) : TT & "/" = "/A/B" : "/" & T & "/" = "/B/" : InStr(TT & "/", "/" & T & "/") = 1 : Long
- ' 6(i) : TT & "/" = "/A/B" : "/" & T & "/" = "/C/" : InStr(TT & "/", "/" & T & "/") = 0 : Long
- ' 7(i) : TT & "/" = "/A/B/C" : "/" & T & "/" = "/A/" : InStr(TT & "/", "/" & T & "/") = 1 : Long
- ' ----------------------------------------------------------------------------------------------
- ' InStr(TT & "/", "/" & T & "/") ªº·N«ä¬°·í²Ä¤@¦¸Åª¨ú¹Lªº¤u§@ªí¦WºÙ·|¼g¤J¨ìÅÜ¼Æ TT ªº¦r¦ê¤¤,
- ' ¦]¬°¤w¸g°µ¹L¿z¿ï¤F, ©Ò¥H·í¦A¦¸Åª¨ú¨ì´¿°O¿ý¹Lªº¦WºÙ®É¸õ¹L, ¦Ó "/" «h¬On°Ï¤À¦U¤u§@ªí¦Wªº°Ï¹j¡A
- ' ¤£·|«ÂСAÅý InStr ®e©ö§PÂ_¡A¦Ó¤£·|²£¥Í¿ù»~ªº§PÂ_¡F
- ' InStr(TT & "/", "/" & T & "/")¡@¥Î "/' ¤À¹j¥i¥H²M·¡¤À§O A, AA, AAA ©Î A1, A11, A111¡A¦Ó¤£·|»~§P¡I
- ' ¦Ó¥B²z½×¤W, ¤u§@ªí¦WºÙ¤£·|¦³ "/" ¦r¤¸¡AY¥Î¨ä¥¦²Å¸¹¡A´Nn¦Ò¼{¤u§@ªíªí¦WºÙ¬O§_§t¦³³oӲŸ¹¡A
- ' ¨Ò¦p¡G ¥Î "-" ¤À¹j¡A´N¥i¯à¹ï 1-1, 1-11, 1-111 ³y¦¨¬Û¦ü¤u§@ªí¦WºÙ¤§»~§P¡I¡I
- ' ----------------------------------------------------------------------------------------------
- On Error Resume Next
-
- Set Sht = Sheets(T)
- On Error GoTo 0
-
- If Sht Is Nothing Then Set Sht = Sheets.Add(after:=Sheets(Sheets.Count)): Sht.Name = T ' Sht ¤£¦s¦b
- Sht.UsedRange.Clear
-
- With xArea
- .Parent.Select ' xArea.Parent.Name = "·JÁ`ªí" : Variant/String
- .AutoFilter Field:=1, Criteria1:=T ' T = "A" : T = "B" : T = "C" : String
- ' AutoFilter ·|¨Ì¾Ú Criteria1 ªº±ø¥ó¶×¶°¡A¼ÐÃD¦ì¸m¨Ã¤£·|²§°Ê
- .Copy Sht.[B1] ' ¥]§t¼ÐÃD»P¤º®e¤@¤@½Æ»s¨ì "A"¡B"B"¡B"C" ¦U§Oªº¤u§@ªí³æ¤º
- End With
-
- TT = TT & "/" & T ' TT = "/A" : TT = "/A/B" : TT = "/A/B/C" ¡G String (§PÂ_¦r¦ê TT ³v¤@¼W¥[)
- 101:
- Next i
-
- ActiveSheet.AutoFilterMode = False ' ¦^´_¨ìì©l³Ìªìªº "·JÁ`ªí" ¤§±Æ§Ç«e¤º®e¶¶§Ç
- End Sub
½Æ»s¥N½X |
-
1
µû¤À¤H¼Æ
-
|