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

[µo°Ý] ¦p¦ó§Q¥ÎVBA«öÁä¡A¨Ó§ä¥X¹H¤Ï³W«hªº¸¹½X¡C

[µo°Ý] ¦p¦ó§Q¥ÎVBA«öÁä¡A¨Ó§ä¥X¹H¤Ï³W«hªº¸¹½X¡C

¸Ô²Ó°ÝÃD¤º®e       
³W«h1. ¦P¼Ëªº¸¹½X¤¤¡A¦bGÄæ¬Û¦Pªº»s³y¤é´Á¤¤¡AEÄ檺¨ì´Á¤é¤]¥²¶·¬Û¦P¡F       
³W«h2. ¦P¼Ëªº¸¹½X¤¤¡A·íGÄ檺»s³y¤é´Á¦³¦hºØ®É¡A«h¶}©l§PÂ_ ­YGÄæ¨Ì¥ý«á±Æ¦C«á¡A¬O§_ EÄ檺¨ì´Á¤é¤]¦³¨Ì¥ý«á¶¶§Ç±Æ¦C¡F       
­Y¹H¤Ï¥H¤W¨âºØ³W«h¥ô¤@¡A«hµø¬°²§±`¸¹½X¡A±N¼u¥Xµøµ¡¨ÃÅã¥Ü¦³­þ¨Ç¸¹½X¹H¤Ï¡C       
µù¡G¼u¥Xµøµ¡°£¤F·|«ü¥X¿ù»~ªº¸¹½X¥~¡A¦pªG¯à¦AÅã¥Ü¬O­þ¤@¤Ñªº»s³y¤é¦³°ÝÃD§ó¦n¡I       
       
¸Ô²Ó°ÝÃD½d¨Ò       
½Ð¨£Àɮפºªº "½d¨Ò»¡©ú­¶"¡C       
       
        ¥H¤W¡A°ÝÃD¨D¸Ñ¡AÁÂÁ¡I¤]§Æ±æ§ÚºÜºÉ©Ò¯àªº¤å·Nªí¹F¯àÅý¦U¦ì¤j¤j¬ÝÀ´¡CXD

¦p¦ó§Q¥ÎVBA«öÁä¡A¨Ó§ä¥X¹H¤Ï³W«h¸¹½X.rar (6.04 KB)

¸Ô²Ó°ÝÃD¤º®e       
³W«h1. ¦P¼Ëªº¸¹½X¤¤¡A¦bGÄæ¬Û¦Pªº»s³y¤é´Á¤¤¡AEÄ檺¨ì´Á¤é¤]¥²¶·¬Û¦P¡F       
³W«h2. ¦P¼Ëªº¸¹ ...
RCRG µoªí©ó 2015-12-11 11:38



    ¤U¥b³¡EÄ檺¨ì´Á¤é§Ñ°O¤W°Ï¶ôÃC¦â¤F....XD

TOP

¦b¢ÖÄæ¦C¥X¿ù»~°T®§¡A
¥ÎMSGBOX¦ê¥X¤@¤j°ï¡AÃö³¬«á§Ñ¥ú¥ú¡A¥Î³B¤£¤j¡I¡I¡I

Sub ÀË´ú()
Dim xD, xD1, R&, T$, TM1&, TM2&, i&
R = [C65536].End(xlUp).Row
[H:H].ClearContents
Set xD = CreateObject("Scripting.Dictionary")
Set xD1 = CreateObject("Scripting.Dictionary")
For i = 2 To R
¡@¡@T = Range("C" & i): TM1 = Int(Range("E" & i)): TM2 = Int(Range("G" & i))
¡@¡@If T = "" Or TM1 = 0 Or TM2 = 0 Then GoTo 101
¡@¡@If TM1 < xD(T) Then xD1(T & TM1) = "¨ì´Á¤é¥¼±Æ§Ç": GoTo 101
¡@¡@xD(T) = TM1
¡@¡@If xD(T & TM2) = 0 Then xD(T & TM2) = TM1
¡@¡@If xD(T & TM2) <> TM1 Then xD1(T & TM2) = "¨ì´Á¤é²§±`": GoTo 101
101: Next
¡@
For i = 2 To R
¡@¡@T = Range("C" & i):  TM1 = Int(Range("E" & i)): TM2 = Int(Range("G" & i))
¡@¡@If xD1(T & TM1) <> "" Then Range("H" & i) = xD1(T & TM1)
¡@¡@If xD1(T & TM2) <> "" Then Range("H" & i) = xD1(T & TM2)
102: Next
End Sub


¡e»s³y¤é¡f¥²¶·¥ý±Æ§Ç¡A¦P½s¸¹ªº¡e¨ì´Á¤é¡f¤ñ¤W­±ªº¤p¡A´Nºâ²§±`¡I¡I

TOP

¦^´_ 3# ­ã´£³¡ªL


   
­ã¤j¦Ò¶qªº¬O¡Aªº½T¦bHÄ檽±µ¥X²{´£¥Ü¤ñ¸û¤è«K¡Aµ{¦¡­n´X¤Ñ«á¤~¯à´ú¸Õ¡A¥ýÁÂÁ­ã¤j¤F¡I

TOP

¥»©«³Ì«á¥Ñ yen956 ©ó 2015-12-13 15:26 ½s¿è

¦p¹Ï:

1.­ì¸ê®Æ¦³¦hµ§ ¨ì´Á¤é<»s³y¤é?
¬O§_­n¼W¥[¦¹§PÂ_?
2. ³W«h2 ¦³¦s¦bªº¤J­n¶Ü?

TOP

¸Õ¸Õ¬Ý:
  1. '´¡¤J§Ç¸¹, ¥H«K«ì´_­ìª¬
  2. Sub ´¡¤J§Ç¸¹(LstR As Integer)
  3.     Dim i As Integer
  4.     For i = 2 To LstR
  5.         Cells(i, 1) = i
  6.     Next
  7. End Sub

  8. Sub test()
  9.     Dim LstR As Integer, LstR2 As Integer, sR As Integer
  10.     Dim mDate1 As Date, mDate2 As Date
  11.     [H2:J65536] = ""
  12.     '²M°£©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¦C¥h°£
  13.     [C:I].Interior.ColorIndex = xlNone
  14.     LstR2 = Cells(Rows.Count, 3).End(xlUp).Row
  15.     ´¡¤J§Ç¸¹ LstR:=LstR2      '´¡¤J§Ç¸¹, ¥H«K«ì´_­ìª¬
  16.     [A1].Resize(LstR2, 10).Sort _
  17.             Key1:=[C1], Order1:=xlAscending, _
  18.             Key2:=[G1], Order1:=xlAscending, _
  19.             Key3:=[E1], Order1:=xlAscending, _
  20.             Header:=xlYes
  21.     LstR = Cells(Rows.Count, 3).End(xlUp).Row
  22.     sR = 2
  23.     mDate1 = DateSerial(Year(Cells(sR, 7)), Month(Cells(sR, 7)), Day(Cells(sR, 7)))
  24.     Do
  25.         '·s¼W²§±`¬ö¿ý,¦pµL¦¹»Ý¨D,½Ð¥h°£
  26.         If Cells(sR, 5) < mDate1 Then    '¨ì´Á¤é<»s³y¤é
  27.             Cells(sR, 8) = "¨ì´Á¤é<»s³y¤é"
  28.            '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¨â¦C¥h°£
  29.             Cells(sR, 8).Interior.ColorIndex = 38
  30.             Cells(sR, 3).Resize(1, 5).Interior.ColorIndex = 38
  31.         End If
  32.         
  33.         If sR = 2 Then GoTo Next1:
  34. '        '¸¹½X¬Û¦P,¨ì´Á¤é¥¼±Æ§Ç(³W«h2 ¦ü¥G¨S¦³¦s¦bªº¥²­n, ¬G¥h°£)
  35. '        If Cells(sR, 3) = Cells(sR - 1, 3) And Cells(sR, 5) < Cells(sR - 1, 5) Then
  36. '            Cells(sR, 10) = "¨ì´Á¤é¥¼±Æ§Ç"
  37. '           '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¦C¥h°£
  38. '            Cells(sR, 3).Resize(1, 5).Interior.ColorIndex = 6
  39. '        End If
  40.         
  41.         '»s³y¤é¬Û¦P, ¦ý¨ì´Á¤é¤£¦P
  42.         If mDate1 = mDate2 And Cells(sR, 5) <> Cells(sR - 1, 5) Then
  43.             Cells(sR - 1, 9) = "¨ì´Á¤é²§±`"
  44.            '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¨â¦C¥h°£
  45.             Cells(sR - 1, 9).Interior.ColorIndex = 8
  46.             Cells(sR - 1, 3).Resize(1, 5).Interior.ColorIndex = 8
  47.             Cells(sR, 9) = "¨ì´Á¤é²§±`"
  48.            '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¨â¦C¥h°£
  49.             Cells(sR, 9).Interior.ColorIndex = 8
  50.             Cells(sR, 3).Resize(1, 5).Interior.ColorIndex = 8
  51.         End If
  52. Next1:
  53.         sR = sR + 1
  54.         mDate1 = DateSerial(Year(Cells(sR - 1, 7)), Month(Cells(sR - 1, 7)), Day(Cells(sR - 1, 7)))
  55.         mDate2 = DateSerial(Year(Cells(sR, 7)), Month(Cells(sR, 7)), Day(Cells(sR, 7)))
  56.     Loop Until sR > LstR
  57.     '«ì´_­ìª¬, ¤è«K¬d®Ö
  58.     [A1].Resize(LstR2, 9).Sort _
  59.             Key1:=[A1], Order1:=xlAscending, _
  60.             Header:=xlYes
  61. End Sub
½Æ»s¥N½X

TOP

¦^´_ 5# yen956


   
1.­ì¸ê®Æ¦³¦hµ§ ¨ì´Á¤é<»s³y¤é? ¬O§_­n¼W¥[¦¹§PÂ_?
¹ê»Ú¤W¬O¤£·|µo¥Í "¨ì´Á¤é<»s³y¤é" ªº¡A®¤§Ú¨SÀˬd¨ì³oµÛ­ÓÁ|¨Ò²¨¥¢¡A³y¦¨»~·|¡ASOR¡IQQ

2. ³W«h2 ¦³¦s¦bªº¤J­n¶Ü?

³W«h2¦³¦s¦b¥²­n­ò¡I¬Æ¦Ü¹ï§Ú¨Ó»¡¤ñ³W«h1ÁÙ­«­n¡A¦]¬°­ì«h¤W»s³y¤é¦­ªºÀ³¸Ó­n¥ý¨ì´Á¡A¦Ó³W«h2´N¬O¦bÀˬd³o­ÓÀô¸`¡I

TOP

°w¹ï ³W«h2 ­×¥¿:
¸Õ¸Õ¬Ý:
  1. '´¡¤J§Ç¸¹, ¥H«K«ì´_­ìª¬
  2. Sub ´¡¤J§Ç¸¹(LstR As Integer)
  3.     Dim I As Integer
  4.     For I = 2 To LstR
  5.         Cells(I, 1) = I
  6.     Next
  7. End Sub
  8. Sub test()
  9.     Dim LstR As Integer, LstR2 As Integer, sR As Integer, I As Integer, cnt As Integer
  10.     Dim minDate As Date
  11.     [H2:J65536] = ""
  12.     '²M°£©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¦C¥h°£
  13.     [C:I].Interior.ColorIndex = xlNone
  14.     LstR2 = Cells(Rows.Count, 3).End(xlUp).Row
  15.     ´¡¤J§Ç¸¹ LstR:=LstR2      '´¡¤J§Ç¸¹, ¥H«K«ì´_­ìª¬
  16.     [A1].Resize(LstR2, 10).Sort _
  17.             Key1:=[C1], Order1:=xlAscending, _
  18.             Key2:=[G1], Order1:=xlAscending, _
  19.             Header:=xlYes
  20.     LstR = Cells(Rows.Count, 3).End(xlUp).Row
  21.     sR = 1
  22.     Do
  23.         cnt = sR
  24.         Do
  25.             sR = sR + 1
  26.             If sR = 2 Then GoTo Next1:
  27.             '³W«h1.»s³y¤é¬Û¦P, ¦ý¨ì´Á¤é¤£¦P
  28.             If Int(Cells(sR, 7)) = Int(Cells(sR - 1, 7)) And Cells(sR, 5) <> Cells(sR - 1, 5) Then
  29.                 Cells(sR - 1, 8) = "¨ì´Á¤é²§±`1"
  30.                '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¨â¦C¥h°£
  31.                 Cells(sR - 1, 8).Interior.ColorIndex = 8
  32.                 Cells(sR - 1, 3).Resize(1, 5).Interior.ColorIndex = 8
  33.                 Cells(sR, 8) = "¨ì´Á¤é²§±`1"
  34.                '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¨â¦C¥h°£
  35.                 Cells(sR, 8).Interior.ColorIndex = 8
  36.                 Cells(sR, 3).Resize(1, 5).Interior.ColorIndex = 8
  37.             End If
  38.         Loop Until Cells(sR, 3) <> Cells(sR - 1, 3) Or sR > LstR  'ª½¨ì ¸¹½X¤£¦P ©Î ¸ê®Æµ²§À
  39.         '³W«h2. ¨ì´Á¤é¤]¥²¶·±Æ§Ç
  40.         If sR - cnt <= 1 Then GoTo Next1:
  41.         For I = cnt To sR - 2
  42.             minDate = Application.Min(Cells(I + 1, 5).Resize(sR - I - 1, 1))
  43.             If Cells(I, 5) > minDate Then
  44.                 Cells(I, 9) = "¨ì´Á¤é²§±`2"
  45.                '¥[¤J©³¦â, ¦p§A­ì¦³©³¦âªº»Ý¨D, ½Ð±N¤U¨â¦C¥h°£
  46.                 Cells(I, 9).Interior.ColorIndex = 38
  47.                 Cells(I, 3).Resize(1, 5).Interior.ColorIndex = 38
  48.             End If
  49.         Next
  50. Next1:
  51.     Loop Until sR > LstR  'ª½¨ì¸ê®Æµ²§À
  52.     '«ì´_­ìª¬, ¤è«K¬d®Ö
  53.     [A1].Resize(LstR2, 9).Sort _
  54.             Key1:=[A1], Order1:=xlAscending, _
  55.             Header:=xlYes
  56. End Sub
½Æ»s¥N½X
°õ¦æµ²ªG¦p¤U¹Ï:

TOP

¦^´_ 8# yen956


    ÁÂÁÂyen¤jªº¸Ñµª¡A¤£¹LI24¦ü¥G¤£¸Ó¥X²{"¨ì´Á¤é²§±`2"¡A¬d¬Ý¤@¤U­ì¦]¦ü¥Gyen¤j§â»s³y¤éªº"®É¶¡"¤]¤ñ¹ï¶i¥h¤F¡I»s³y¤é¥u»Ý¤ñ¹ï"¤é´Á"¡A«á­±®É¶¡¥i¥H©¿²¤¡F
¥t¥~AÄ檺§Ç¸¹¥Î·N¬O¡H³o¬O¤@©w³£·|¥X²{¶Ü?

TOP

Q2:¥t¥~AÄ檺§Ç¸¹¥Î·N¬O¡H³o¬O¤@©w³£·|¥X²{¶Ü?
VBA52¦C¤£¬O»¡ªº«Ü²M¶Ü?
¦pµL¦¹»Ý¨D, «h¬ÛÃöVBACode¥h±¥§Y¥i.
Q1:³o¤£¬O§A¦Û¤v­qªº³W«h2.¶Ü?¦p¤U¹Ï:

test.jpg (1.61 KB)

test.jpg

TOP

        ÀR«ä¦Û¦b : ¤H­nª¾ºÖ¡B±¤ºÖ¡B¦A³yºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD