- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-11-4 10:24 ½s¿è
¦^´_ 4# samwang
ÁÂÁ«e½ú«ü¾É
¶Wµuªº®É¶¡!¼F®`!
¥H¤U¬O°õ¦æµ²ªG»P¤ß±oµù¸Ñ,½Ð«e½ú¦A«ü¾É!
«á¾Ç¹ï¸Ñ¨M°ÝÃDªº±Ò©l³£µLÀYºü!¶Ã¸Õ! ¥é¿ù¤èªk! ¤S¼Ò¥éªº¥|¤£¹³!
¾ÉP®Ä²v¤£¹ü! ¦Û¤vªºµù¸Ñ¤]¿ùµù!
ÁÂÁ«ü¾É
²Ä¤@¦C¥¼²M°£®É:
³Ì«áµ²ªG:
Option Explicit
Sub test_samwang()
Dim Arr, Brr(1 To 10000, 1 To 100), xD, R&, C%, Sh
Dim xR As Range, x%, y$, x1%, j%, crl, T
'¡ô«Å§iÅܼÆ!¦hÓÅܼƬOµu¾ã¼Æ!¨S¥Îªø¾ã¼Æ!¤£ª¾®Ä²v¬O§_¦³®t?¦A¬ã¨s!
T = Timer
Set xD = CreateObject("Scripting.Dictionary")
'¡ô¥OxD¬O¦r¨å
Set Sh = Sheets("¾Þ§@ªí")
'¡ô¥OSh ¬O ¾Þ§@ªí
R = Sh.UsedRange.EntireRow.Rows.Count
'¡ô¥OR ¬O¦³¨Ï¥Îªº¦C¼Æ
C = Sh.UsedRange.EntireColumn.Columns.Count
'¡ô¥OC ¬O¦³¨Ï¥ÎªºÄæ¼Æ
Set Arr = Range(Sh.[a1], Sh.Cells(R, C))
'¡ô¥OArr¬OÀx¦s®æ¶°!½d³ò¬O³Ì¤jªº¤w¨Ï¥Î®æ½d³ò
For Each xR In Arr
'¡ô³]¶¶°j°é!¥OxR ¬OArrÀx¦s®æ¶°ªº¤@û
If IsNumeric(xR.Value) = False Or xR.Value = "" Then GoTo 888
'¡ô¦pªG °}¦CȤ£¬O¼Æ¦r ©Î °}¦CȬOªÅ¦r¤¸! ´N¸õ¨ì 888¦ì¸mÄ~Äò°õ¦æ
crl = xR.Interior.Color
'¡ô¥tcrl ¬O©³¦âÃC¦â¸¹
y = 2
'¡ô¥Oy ¨C¦¸ªº°j°éªì©lȳ£¬O 2!³o¬OBrr°}¦C¸Ìªºµ²ªG¦C¼Æ(¥H¤UºÙ_Brrµ²ªG¦C)
'¦]¬°³o¬On±q²Ä3¦C¶}©l©ñ©ú²ÓÈ!©Ò¥Hªì©lȬO2Åý«áµ{§Ç¥[ 1=3!
'¦¹ÈˤJ¦r¨å xD(crl)«á¦AÄ~Äò²Ö¥[ 1
If xD.Exists(crl) Then
'¡ô¦pªG¥H xR©³¦âÃC¦â¸¹¬°KEY¬d¹î xD¦r¨å¬O¦³¦¹Áä!
y = xD(crl)
'¡ô±ø¥ó¦¨¥ß!´N¥Oy ¬O¦r¨å¸Ì¹ïÀ³key¬° (xR©³¦âÃC¦â¸¹)ªºitemÈ
x1 = xD(crl & "_C")
'¡ô±ø¥ó¦¨¥ß!´N¥Ox1 ¬O¦r¨å¸Ì¹ïÀ³key¬° (xR©³¦âÃC¦â¸¹& "_C")ªºitemÈ
'x1¬O¦bBrr°}¦C¸Ìªºµ²ªGÄæ¼Æ(¥H¤UºÙ_Brrµ²ªGÄæ)ªº·N«ä
Brr(2, x1) = Brr(2, x1) + xR.Value
'¡ô±ø¥ó¦¨¥ß!´NÅýBrr°}¦C¸Ì(²Ä2¦C/Brrµ²ªGÄæ)¹ïÀ³ªº¦ì¸mÈ»P ArrÀx¦s®æ_xRȲ֥[
Brr(y + 1, x1) = xR.Value
'¡ô±ø¥ó¦¨¥ß!´NÅýBrr°}¦C¸Ì(²ÄyÅܼÆ+1¦C/Brrµ²ªGÄæ)¹ïÀ³ªº¦ì¸mµ¥©ó ArrÀx¦s®æ_xRÈ
xD(crl) = y + 1
'¡ô±ø¥ó¦¨¥ß!Brrµ²ªG¦C²Ö¥[ 1
Else
'¡ô¦pªG±ø¥ó¤£¦¨¥ß! °j°éªº¤@¶}©l±ø¥ó¤£·|¦¨¥ß! ²Ä¤@¦¸¹J¨ì¤£¦P©³¦â ±ø¥ó¤]¤£·|¦¨¥ß!
x = x + 1
'¡ôx¬Oµu¾ã¼Æ!ªì©lȬO0! ²Ö¥[ 1!³o¬O ©³¦âÃC¦â¸¹ªººØÃþ¼Æ!
'¹J¨ì¦r¨å¸Ì¨S¦³ªº ©³¦âÃC¦â¸¹ºØÃþ®É!´Nn¥[ 1
Brr(1, x) = crl
'¡ôBrr°}¦C(²Ä¤@¦C/Brrµ²ªGÄæ1)ȵ¥©ó ©³¦âÃC¦â¸¹
Brr(2, x) = xR.Value
'¡ôBrr°}¦C(²Ä¤G¦C/Brrµ²ªGÄæ1)ȵ¥©ó ArrÀx¦s®æ_xRÈ(²Ä¤@ӼƦr¥[Á`È)
y = y + 1
'¡ôyªº«Å§i¬O¦r¦ê!¼Æ¦r¦r¦ê¬O¥i¥H°µ¼Æ¾Ç¹Bºâªº!¶W°ª¿³!¾Ç¨ì¤F!
'yªº²Ä¤@ȬO "2" + 1 «á¬O "3"
Brr(y, x) = xR.Value
'¡ôBrr°}¦C(²Ä¤T¦C/Brrµ²ªGÄæ1)ȵ¥©ó ArrÀx¦s®æ_xRÈ(²Ä¤@Ó©ú²ÓÈ)
xD(crl) = y
'¡ô§â©³¦âÃC¦â¸¹¬°key,ˤJ¦r¨å¤¤,item¬O 3
xD(crl & "_C") = x
'¡ô§â(©³¦âÃC¦â¸¹ & "_C")¦r¦ê ¬°key,ˤJ¦r¨å¤¤,item¬O «e¤èªº©³¦âÃC¦â¸¹ªººØÃþ¼Æ1
End If
888: Next
Workbooks.Add
[a1] = "ÃC¦â¡÷": [A2] = "¼Æ¦r¥[Á`¡÷": [A3] = "¡õ¥H¤U¬O©ú²Ó"
[B1].Resize(1000, x) = Brr
'¡ô±q¤u§@ªí[B1]¶}©l¶K¤JBrr°}¦C¸ê®Æ
For j = 1 To x
'¡ô³]¶¶°j°é!±q1 ¨ì ©³¦âÃC¦â¸¹ªººØÃþ³Ì«á²Ö¥[¼Æ
Cells(1, j + 1).Interior.Color = Brr(1, j)
'¡ô§â²Ä¤@¦Cªº©³¦â¥Î¤º®e¸Ìªº©³¦â¸¹¤W¦â
Next
Range(Cells(1, 2), Cells(1, x + 1)) = ""
'¡ô§â²Ä¤@¦Cªº©³¦â¸¹²M°£
Cells.Columns.AutoFit
'¡ô¥þ³¡Äæ¦ì¦Û°Ê½Õ¾ãÄæ¼e
Cells.Borders.LineStyle = 1
'¡ô¥þ³¡Àx¦s®æ®æ½u¬°²Ó¹ê½u
MsgBox Timer - T & " ’"
End Sub
¬Ý±oÀ´¬OÀ³¸Óªº!·|¥Î¤S¬O¥t¤@¦^¨Æ!¶Ô½m´N¹ï¤F! |
|