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

[µo°Ý] ¨D§U~±Æµ{¶ñ¤J¤é´Á

[µo°Ý] ¨D§U~±Æµ{¶ñ¤J¤é´Á

¥Ñ©ó¤p§Ìªº¥¨¶°¥\¤O¤£¨¬¡A·Q½Ð±ÐªO¤W¦U¦ì°ª¤â¤U­±³o­Ó°ÝÃD~
·Q­n±N¥X³f¤é

©î¶}¨ì¦U¤l§åªº¥æ´Á

¦p»¡©ú

¸÷¨D¦U¦ì¤j¤j¨ó§U~ÁÂÁ¡I
±Æµ{°ÝÃD.rar (4.82 KB)
Adam

Dear  Hsieh¤j¡A·PÁ±zªº¦^ÂСA´ú¸ÕµL»~
¥Ø«e´ú¸Õ±z¸òstillfish00©Ò´£¨Ñªº§¡¥¿½T¡A§Ú¦A¬ã¨s¬Ý¬Ý¨âªÌªº®t²§¡AÁÂÁ¡I
Adam

TOP

¦^´_ 10# adam2010
Lookup¨ç¼Æ¨Ã¤£¾A¥Î
  1. Sub ex()
  2. Dim Ar(), Ay(), C As Range, rng As Range
  3. Set d = CreateObject("Scripting.Dictionary") '¼Æ¶q
  4. Set d1 = CreateObject("Scripting.Dictionary") '¤é´Á
  5. With Sheets("¥X³f¤é")
  6. For Each a In .Range(.[A2], .[A2].End(xlDown)) 'ª«®Æ
  7.   Set rng = a.EntireRow.SpecialCells(xlCellTypeConstants, xlNumbers) 'À³¥æ³f¼Æ¶q
  8.      For Each C In rng
  9.         cnt = cnt + C
  10.         ReDim Preserve Ar(s)
  11.         ReDim Preserve Ay(s)
  12.         Ar(s) = cnt
  13.         Ay(s) = .Cells(1, C.Column).Value
  14.         s = s + 1
  15.      Next
  16.      d(a.Value) = Ar
  17.      d1(a.Value) = Ay
  18.      Erase Ar: Erase Ay: s = 0: cnt = 0
  19. Next
  20. End With
  21. With Sheets("¥æ´Á")
  22.   For Each a In .Range(.[A2], .[A2].End(xlDown))
  23.      cnt = cnt + a.Offset(, 3)
  24.      If cnt <= Application.Max(d(a.Value)) Or cnt - a.Offset(, 3) < Application.Max(d(a.Value)) Then
  25.      i = 0
  26.      Do Until cnt - a.Offset(, 3) < d(a.Value)(i) Or i = UBound(d(a.Value))  '§ä¨ì°}¦C¤¤¤ñ¤w¥æ³f¼Æ¶qÁÙ¤jªºÀ³¥æ³f¼Æ¶q
  27.      n = d(a.Value)(i)
  28.        i = i + 1
  29.      Loop
  30.      a.Offset(, 4) = d1(a.Value)(i)
  31.      Else
  32.      a.Offset(, 4) = "NA"
  33.      End If
  34.      If a <> a.Offset(1) Then cnt = 0
  35.   Next
  36. End With
  37. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

·PÁÂDino¤j,Hsieh¤j¥H¤Îstillfish00¤jªº¨ó§U¡A
´ú¸ÕµL»~¡A¸Ñ¨M§Úªñ´X¶gªº§xÂZ¡A¤Ó·P°Ê¤F¡AÁÂÁ¡I
Adam

TOP

¦^´_ 8# adam2010
  1. Sub Test()
  2. Dim rng As Range
  3. Dim s1 As Long, s2 As Long
  4. Dim cindex As Long

  5. With Sheets("¥X³f¤é")
  6.     Set rng = .Range(.[A1], .[A1].End(xlToRight).End(xlDown).Offset(, -1))  '[¥X³f¤é]¸ê®Æ½d³ò
  7. End With

  8. For Each c In Sheets("¥æ´Á").Range("E2:E" & Sheets("¥æ´Á").[A1].End(xlDown).Row)   '[¥æ´Á]¸ê®Æ¶ñ¤J½d³ò
  9.     If c.Offset(, -4).Value <> c.Offset(-1, -4).Value Then
  10.         cindex = 1
  11.         s1 = 0  '²Ö¿n¦Ü«e¤@§å¼Æ¶q
  12.         s2 = 0  '²Ö¿n¥X³f»Ý¨D¼Æ¶q
  13.     Else
  14.         s1 = s1 + c.Offset(-1, -1).Value
  15.     End If
  16.    
  17.     Do While s2 <= s1
  18.         cindex = cindex + 1
  19.         If Application.IsError(Application.VLookup(c.Offset(, -4).Value, rng, cindex, False)) Then
  20.             Exit Do
  21.         Else
  22.             s2 = s2 + Application.VLookup(c.Offset(, -4).Value, rng, cindex, False)
  23.         End If
  24.     Loop
  25.    
  26.     If s2 <= s1 Then
  27.         c.Value = "NA"
  28.     Else
  29.         c.Value = rng.Cells(1, cindex).Value
  30.     End If
  31. Next
  32. Set rng = Nothing
  33. End Sub
½Æ»s¥N½X

TOP

Dear Hsieh¤j~·PÁ±z¥X¤â¬Û§U
Sheets("¥æ´Á")ªºDÄæ¼Æ¶q¬O¤½¥q³øªí¿z¥X¨Óªº~
¥Î¤½¥qªº¸ê®Æ´ú¸Õ¹L¤§«áHsieh¤jªº¥¨¶°¸Ñ¨M¤F§ä¤£¨ì·|°±¤îªº°ÝÃD¡A¤£¹L¤é´Á¦³¨Ç¥X¤J

......¦½ÃC§ä¤£¥X°ÝÃD©Ò¦b¡A©Ò¥H¦A¦¸¨D§U¡AÁÂÁ¡I
Test-1.rar (31.57 KB)
Adam

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2013-1-12 00:10 ½s¿è

¦^´_ 8# adam2010
Sheets("¥æ´Á")ªºDÄæ¼Æ¶q¬O¤H¤u¥ý¿é¤J¦nªº¶Ü?
¸Õ¸Õ¬Ý
  1. Sub ex()
  2. Dim Ar(), Ay(), C As Range, Rng As Range
  3. Set d = CreateObject("Scripting.Dictionary") '¼Æ¶q
  4. Set d1 = CreateObject("Scripting.Dictionary") '¤é´Á
  5. With Sheets("¥X³f¤é")
  6. For Each a In .Range(.[A2], .[A2].End(xlDown)) 'ª«®Æ
  7.   Set Rng = a.EntireRow.SpecialCells(xlCellTypeConstants, xlNumbers) '­q³f
  8.   ReDim Preserve Ar(s) '¼Æ¶q
  9.   ReDim Preserve Ay(s) '¤é´Á
  10.   Ar(s) = 0
  11.   Ay(s) = .Cells(1, Rng.Column)
  12.   s = s + 1
  13.      For Each C In Rng
  14.         cnt = cnt + C
  15.         ReDim Preserve Ar(s)
  16.         ReDim Preserve Ay(s)
  17.         Ar(s) = cnt
  18.         Ay(s) = .Cells(1, C.Column).Value
  19.         s = s + 1
  20.      Next
  21.      d(a.Value) = Ar
  22.      d1(a.Value) = Ay
  23.      Erase Ar: Erase Ay: s = 0: cnt = 0
  24. Next
  25. End With
  26. With Sheets("¥æ´Á")
  27.   For Each a In .Range(.[A2], .[A2].End(xlDown))
  28.      cnt = cnt + a.Offset(, 3)
  29.      If cnt <= Application.Max(d(a.Value)) Or cnt - a.Offset(, 3) < Application.Max(d(a.Value)) Then _
  30.      a.Offset(, 4) = Application.Lookup(cnt, d(a.Value), d1(a.Value)) _
  31.      Else a.Offset(, 4) = "NA"
  32.      If a <> a.Offset(1) Then cnt = 0
  33.   Next
  34. End With
  35. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¤Ó·P°Ê¤F!·PÁÂstillfish00¤j¤jªº¨ó§U¡A³o¸Ì¯u¬O°ª¤â¦p¶³¡A¨C­Ó³£¬O¤j®v¯Åªº
­è¤~¸Õ¤F ¤@¤U§¹¥þ²Å¦X§Úªº»Ý¨D¡A¤£¹L®M¥Î¨ì¤½¥q¥¿¦¡ªº¤j«¬ÀÉ®×µo²{ÁÙ¦³2­Ó¤p°ÝÃD
1.For Each c In Sheets(1).[E2:E15]    '[¥æ´Á]¸ê®Æ¶ñ¤J½d³ò¡÷¦pªG½d³ò¬OÅܰʪº¸Ó¦p¦ó­×§ï
2.¦pªG¹J¨ì¥æ´Á¸Ì­±¦³¦ý¬O¥X³f¤é¨S¦³ªºª«®Æ´N·|¦]¬°§ä¤£¨ì¥d¦b21¦æ¡÷­n¦p¦ó¼W¥[¤@­Ó§P§OÅý§ä¤£¨ìªº¤]Åã¥ÜNA
¸Ñ¨M¤F³o2­Ó°ÝÃDÀ³¸Ó´N«Ü§¹¬ü¤F
Adam

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-1-11 14:15 ½s¿è

¦^´_ 6# adam2010
¸Õ¸Õ¬Ý
  1. Sub Test()
  2. Dim rng As Range
  3. Dim s1 As Long, s2 As Long
  4. Dim cindex As Long

  5. With Sheets(2)
  6.     Set rng = .Range(.[A1], .[A1].End(xlToRight).End(xlDown).Offset(, -1))  '[¥X³f¤é]¸ê®Æ½d³ò
  7. End With

  8. For Each c In Sheets(1).[E2:E15]    '[¥æ´Á]¸ê®Æ¶ñ¤J½d³ò
  9.     If c.Offset(, -4).Value <> c.Offset(-1, -4).Value Then
  10.         cindex = 1
  11.         s1 = 0  '²Ö¿n¦Ü«e¤@§å¼Æ¶q
  12.         s2 = 0  '²Ö¿n¥X³f»Ý¨D¼Æ¶q
  13.     Else
  14.         s1 = s1 + c.Offset(-1, -1).Value
  15.     End If
  16.    
  17.     Do While s2 <= s1 And cindex < rng.Columns.Count
  18.         cindex = cindex + 1
  19.         s2 = s2 + Application.VLookup(c.Offset(, -4).Value, rng, cindex, False)
  20.     Loop
  21.    
  22.     If s2 <= s1 Then
  23.         c.Value = "NA"
  24.     Else
  25.         c.Value = rng.Cells(1, cindex).Value
  26.     End If
  27. Next
  28. Set rng=Nothing
  29. End Sub
½Æ»s¥N½X

TOP

¦A¸É¥R¤@ÂI´N¬O¦³®É­Ô¤]·|¦³
¦³­q³æ¡A¦ý¬O©|¥¼§ë®Æªºª¬ªp¡A©Ò¥H¥u­n±N¥æ´Á¤À°t¨ì¦P¤@­Óª«®Æªº§å¸¹µ²§ô§Y¥i
Adam

TOP

        ÀR«ä¦Û¦b : §Ú­Ì­n°µ¦nªÀ·|ªºÀô«O¡A¤]­n°µ¦n¤º¤ßªºÀô«O¡C
ªð¦^¦Cªí ¤W¤@¥DÃD