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

[µo°Ý] ½Ð°Ý­n¦p¦ó¤Á³Î¼Æ¾Ú¥H¤è«K°µ¹Ï¡H

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-12-20 22:01 ½s¿è

¦^´_ 1# Genie
  1. Sub test()
  2.     Dim ar, d, arEQ, i As Long
  3.    
  4.     '½Æ»s¨Ó·½
  5.     With Sheets("Sheet1")
  6.         .AutoFilterMode = False
  7.         .[A1].CurrentRegion.Copy Sheets("Sheet2").[A1]
  8.         .[A1].AutoFilter
  9.     End With
  10.    
  11.     With Sheets("Sheet2")
  12.         '±Æ§Ç
  13.         With .Sort
  14.             .SortFields.Clear
  15.             .SortFields.Add .Parent.Range("B2:B" & Rows.Count), xlSortOnValues, xlAscending
  16.             .SortFields.Add .Parent.Range("C2:C" & Rows.Count), xlSortOnValues, xlAscending
  17.             .SetRange .Parent.[A1].CurrentRegion
  18.             .Header = xlYes
  19.             .Orientation = xlTopToBottom
  20.             .SortMethod = xlPinYin
  21.             .Apply
  22.         End With
  23.         
  24.         '§ä¥X¨C¬q°_©l¦ì¸m
  25.         ar = .[A1].CurrentRegion.Value
  26.         Set d = CreateObject("scripting.dictionary")
  27.         For i = 2 To UBound(ar)
  28.             If ar(i, 2) <> ar(i - 1, 2) Then d(ar(i, 2)) = i
  29.         Next i
  30.         
  31.         '¥Ñ«á©¹«e¤À³Î¡A´¡¤JªÅ¥Õ
  32.         arEQ = d.keys
  33.         For i = UBound(arEQ) To LBound(arEQ) + 1 Step -1
  34.             .Range(.Cells(d(arEQ(i)), "D"), .Cells(.Rows.Count, "D")).Insert xlToRight
  35.             .Rows(d(arEQ(i))).Insert xlDown
  36.         Next i
  37.         .[D1].Resize(, d.Count).Value = d.keys
  38.     End With
  39. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# Genie
¥i¯à§Aªºª©¥»¤ñ¸û¡A»yªk¤£¤ä´©
§â±Æ§Ç¨º¬q´«¦¨
  1.         '±Æ§Ç
  2.         .[A1].CurrentRegion.Sort key1:=.[B1], order1:=xlAscending, key2:=.[C1], order2:=xlAscending, Header:=xlYes, Orientation:=xlTopToBottom
½Æ»s¥N½X
¸Õ¬Ý¬Ý

TOP

¦^´_ 5# Genie
¥i¯à§a...§Ú¨S¿ìªk´ú¸Õª©¥»
¼gªk«Ü¦hºØ¡A¦Û¤v¸Õ¸Õ§a
ar = Range(.[A1],.[A1].end(xldown)).resize(,4).Value

TOP

        ÀR«ä¦Û¦b : ¬O«D·í±Ð¨|¡AÆg¬ü§@ĵ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD