- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¦^´_ 10# ã´£³¡ªL
ÁÂÁ½׾Â,ÁÂÁ«e½ú
«á¾ÇÂǦ¹©«¾Ç²ß«e½úªº¤è®×,¾Ç²ß¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú¦A«ü¾É
°õ¦æ«e:
°õ¦æµ²ªG:
Sub ¶ñ¦â()
Dim xDic, xR As Range, TR, CC%
'¡ô«Å§iÅܼÆ
If Not IsDate([C1]) Then MsgBox "¤é´Á®É¶¡¥¼¿é¤J! ": Exit Sub
'¡ôÀË´ú[C1]»Ýn¿é¤J¥¿½T¤é´Á®É¶¡
Set xDic = CreateObject("Scripting.Dictionary")
'¡ô¥OxDic¬O¦r¨å
For Each xR In Range([A1], [A65536].End(xlUp))
'¡ô³]³v¶µ°j°é!¥OxR¬OAÄ檺Àx¦s®æ
If xR.Row > 1 And xR <> "" Then xDic(xR.Value) = Array(99, 0, 0)
'¡ô¨Ò¥~®Æ¸¹,¥H99¬°ÃѧO½X
'¥HxRÀx¦s®æȬ°key,item¬O¤@ºû°}¦C,0¯Á¤Þ¸¹È¬O99
Next
For Each xR In Range([C3], [C65536].End(xlUp))
'¡ô³]³v¶µ°j°é!¥OxR¬OCÄ檺Àx¦s®æ
If xR = "" Or Not IsDate(xR(1, 4)) Then GoTo 101
'¡ô¦pªGµL®Æ¸¹©Î«D¤é´Á,¸õ¨ì101¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
TR = xDic(xR.Value)
'¡ô¥OTRÅܼƬOxRÅܼƬdxDic¦r¨å¦^¶ÇªºitemÈ(¨ú¥X¦r¨åÀÉITEM)
If Not IsArray(TR) Then TR = Array(0, 0, 0)
'¡ô¦pªGTRÅܼÆÁÙ¤£¬O°}¦C!´N¥OTRÅܼƬO¤@ºû°}¦C(º¦¸¤J¦r¨åªÌ, ©ñ¤J¹w³]°}¦C)
If TR(0) = 99 Then GoTo 101
'¡ô¦pªGÃѧO½X¬°99, ªí¥Ü¬°¨Ò¥~, ©Î¤£²Å³W«h,¸õ¨ì101¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
If xR(1, 4) > [C1] And TR(1) = 0 Then TR(0) = TR(0) + 10: TR(1) = 1
'¡ô¦pªGxRÀx¦s®æ(§t)¥k°¼²Ä4®æ¤j©ó[C1]Àx¦s®æ®É¶¡,¦Ó¥B1¯Á¤Þ¸¹TR°}¦C¬O0 !
'´N¥O0¯Á¤Þ¸¹TR°}¦CȲ֥[10(¬O0¥[10¬°ÃѧO½X),¥O1¯Á¤Þ¸¹TR°}¦CȬO1
If xR(1, 4) < [C1] Then
'¡ô¦pªG¤é´ÁÄæȤp©ó[C1]È®É?
If TR(2) = 0 Then TR(0) = TR(0) + 1: TR(2) = Int(xR(1, 4))
'¡ôTR°}¦C2¯Á¤Þ¸¹ÈY¬°0, ªí¥Ü¬°²Ä1Ó¤é´Á,¶ñ¤J¤é´Á, ÃѧO½X¥[1
If Int(xR(1, 4)) <> TR(2) Then TR(0) = 99
'¡ôY¤é´Á¤£¬Û¦P, ªí¥Ü¤p¤_C1¤é´Á¶W¹L2Ó,¥H99¬°ÃѧO½X
End If
xDic(xR.Value) = TR
'¡ô¥HxRÀx¦s®æÈ·íkey,item¬OTRÅܼÆ(¤@ºû°}¦C),¯Ç¤JxDic¦r¨å
101: Next
For Each xR In Range([C3], [C65536].End(xlUp))
'¡ô³]³v¶µ°j°é!¥OxR¬OCÄ檺Àx¦s®æ
If xR = "" Or Not IsDate(xR(1, 4)) Then GoTo 102
'¡ô¦pªGµL®Æ¸¹©Î«D¤é´Á,¸õ¨ì102¼Ð¥Ü¦ì¸mÄ~Äò°õ¦æ
TR = xDic(xR.Value): CC = 0
'¡ô¥OTRÅܼƲ±¥X xRÀx¦s®æȦbxDic¦r¨å¸Ìªºitem(¤@ºû°}¦C):¥OCCÅܼÆÂk¹s
If TR(0) = 10 Then CC = 3
'¡ô¦pªG¥u¦³¤j¤_C1¤é´Á ,0¯Á¤Þ¸¹TR°}¦CȬO10(ÃѧO½X = 10),´N¥OCCÅܼƬO3
If TR(0) = 11 And xR(1, 4) < [C1] Then CC = 7
'¡ô¦pªG¦³¤j¤_C1¤é´Á, ¥B¤p¤_C1¤é´Á¥u¦³¤@Ó, ÃѧO½X=10+1),´N¥OCCÅܼƬO7
If CC > 0 Then xR.Resize(1, 4).Interior.ColorIndex = CC
'¡ô¤W©³¦â
102: Next
End Sub |
|