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

[µo°Ý] ½Ð°Ý¦p¦ó¥ÎVBA¹F¨ì¦h­«¿z¿ï¡A¥H¤Î¿z¿ï«á¨Ì§Ç¶ñ¤J??

[µo°Ý] ½Ð°Ý¦p¦ó¥ÎVBA¹F¨ì¦h­«¿z¿ï¡A¥H¤Î¿z¿ï«á¨Ì§Ç¶ñ¤J??

1.§PÂ_­ì«h¬°:·í¬Y¤H(¤ý¤p©ú)¥Ø«e°ê¤å¬ì¥ØÁ`¦@ªá¤F300¤ÀÄÁ¡A¨º»ò­p¹ºªí¤¤´NÅã¥Ü¦b¡y¹ê»Úªá¶O®É¶¡¡z¤¤ªº²Ä¤G¶i«×(°ê¤å)180¡A³Ñ¾lªº120Âk¨ì²Ä¤­¶i«×(°ê¤å)¤¤¡A¤]´N¬O¤@ª½ÂkÃþ¨ì¹ê»Úªá¶O®É¶¡¤p©ó¹w­pªá¶O®É¶¡¡A©Î¦b¤U¤@Äæ¦ì¤w¸g¨S¦³¦¹¬ì¥ØŪ®Ñ­pµe¶i«×¤~®e³\¹ê»Úªá¶O®É¶¡¤j©ó¹w­pªá¶O®É¶¡(¥H¾ú¥v¬°¨Ò¡A·N«ä¤]´N¬OÂk¨ì¨S¦³¿ìªk¦A©¹¤UÂk¤~§â©Òªá¶O®É¶¡¶ñ¤J³Ì«áªºÅª®Ñ¶i«×)                                       
2.¦pªG¥Î¨ç¼Æ¬O¥i¥H¿ì¨ì¤W­z©ÒÁ¿ªº¡A¦ý¬O¨C­Ó¤HŪ®Ñ­pµe³£¤£¤@¼Ë¥H¤Î¨C¤ÑŪ®Ñ­pµe¤]·|¦³ÅÜ°Ê¡A·í¾Ç¥Í¦h´N­nªá¶O§ó¦h®É¶¡¡F¥H¤Î¨C¤Ñ­pµe³£¤£¤@¼Ë¡A¾É­P¨C¤Ñ³£­n­«°µ¤@¦¸¡A©Ò¥H¤~·Q»¡¦³¨S¦³¥i¥H¥ÎVBAªº¤è¦¡¿z¿ï¾Ç¥Í»P¬ì¥Ø«á¡A¦A§Q¥Î§PÂ_¹w­p®É¶¡»P¹ê»Ú®É¶¡ªº¤j¤p°µ©¹¤U¶ñ¤Jªº°Ê§@¡A¦Ó·í§PÂ_¨ì¤U¤@Äæ¦ì¤w¸g¨S¦³¦¹¬ì¥Ø«á¡A§Y¨Ï¹ê»Ú®É¶¡¤ñ¹w­p®É¶¡¤j¤~¥i¶ñ¤J       

½Ð°Ñ¦Ò¤@¤U§Ú©Ò§Æ±æ¹F¨ì¥ØªºªºÀɮסA³o¼Ë¦U¦ì«e½ú­Ì¤]¤ñ¸û¤F¸Ñ
https://sites.google.com/site/yanto913/data/Plan.xls
½Ð¦U¦ì«e½ú­ÌÀ°¤@¤U¦£¡AÁÂÁÂ^^
YOYO

¦^´_ 1# yanto913
  1. Sub Ex()
  2. Set dic = CreateObject("Scripting.Dictionary")
  3. Set dicn = CreateObject("Scripting.Dictionary")
  4. With Sheet2
  5. For Each a In .Range(.[H2], .[H65536].End(xlUp))
  6.    dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) + a.Offset(, 2)
  7. Next
  8. For Each a In .Range(.[A2], .[A65536].End(xlUp))
  9.    dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) + 1
  10. Next
  11. For Each a In .Range(.[A2], .[A65536].End(xlUp))
  12.     If a <> "" Then
  13.     mytime = Application.Min(a.Offset(, 4), dic(a & a.Offset(, 1)))
  14.     If dicn(a & a.Offset(, 1)) = 1 Then
  15.        a.Offset(, 5) = Val(dic(a & a.Offset(, 1)))
  16.        Else
  17.        a.Offset(, 5) = mytime
  18.        dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) - 1
  19.        dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) - mytime
  20.     End If
  21.     End If
  22. Next
  23. End With
  24. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

ÁÂÁª©¥D¤j¤H¡A­è¦n¥i¥H§Q¥Î»ä­·¤ÑÆp¬ã¤@¤UVBA¡A¦]¬°¥\¤O¤£°÷¤§«e¤j³¡¤À³£¬O¥Î¿ý»sªº¤èªk
¡AÁÙ¦n¦³ª©¥DÀ°¦£¡A¤£µM³o¦¸§Ú¯uªº¼g¤£¥X¨Ó®º!!¤§«á·|¦n¦nÁA¸ÑùØ­±ªº²[¸qªº¡AÁÂÁ¡C
YOYO

TOP

²{¦b¹J¨ì¤F¤@­Ó°ÝÃD­C¡A¦pªG§Úªº¹ê»ÚŪ®Ñ®É¶¡¬O¦bsheet3¡A§ï¦¨¤U¦C´N¥X²{¿ù»~¤F¡I¡I
For Each a In .Sheets("sheet3").Range(.[H2], .[H65536].End(xlUp))
¼u¥X¡÷µøµ¡»¡§ä¤£¨ì¤èªk©Î¸ê®Æ¦¨­û
­Y§ï¦¨¤U¦C
For Each a In Sheets("sheet3").Range(.[H2], .[H65536].End(xlUp))
¼u¥X¡÷ª«¥ó©ÎÀ³¥Îµ{¦¡©w¸q¤Wªº¿ù»~
https://sites.google.com/site/yanto913/data/Plan2.xls
YOYO

TOP

§Ú§Ë¦n¤F¡A­ì¨Ó¬O­n¶K¦b¨Ó·½¨ºÃä¡AµM«á§Ú§âWith Sheet3®³±¼¤F
Sub Ex()
Set dic = CreateObject("Scripting.Dictionary")
Set dicn = CreateObject("Scripting.Dictionary")
For Each a In Sheets("sheet3").Range([H2], [H65536].End(xlUp))
   dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) + a.Offset(, 2)
Next
For Each a In Sheets("sheet1").Range(Sheets("sheet1").[A2], Sheets("sheet1").[A65536].End(xlUp))
   dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) + 1
Next
For Each a In Sheets("sheet1").Range(Sheets("sheet1").[A2], Sheets("sheet1").[A65536].End(xlUp))
    If a <> "" Then
    mytime = Application.Min(a.Offset(, 4), dic(a & a.Offset(, 1)))
    If dicn(a & a.Offset(, 1)) = 1 Then
       a.Offset(, 5) = Val(dic(a & a.Offset(, 1)))
       Else
       a.Offset(, 5) = mytime
       dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) - 1
       dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) - mytime
    End If
    End If
Next
End Sub

­è­è¤Wºô¬d¤F¤@¤U¥ÎWith Sheet3¥i¥H¨ú¥NSheets("sheet3")
¤]´N¬Oµ{¦¡¥ÑSheets("sheet3").Range([H2], [H65536].End(xlUp))
Åܦ¨.Range(.[H2], .[H65536].End(xlUp))
¤£ª¾¹D¬°¤°»ò.[H2], .[H65536]¤]³£­n¦h¤@­Ó¤pÂI. ©O¡H¡H³o§Ú´N¤£ª¾¹D¤F
YOYO

TOP

¦^´_ 5# yanto913
½Ð°Ñ¾\VBA»¡©úÀÉ
With ³¯­z¦¡¥iÅý±z¹ï¬Y­Óª«¥ó°õ¦æ¤@¨t¦Cªº³¯­z¦¡¡A¦Ó¤£¥Î­«½Æ«ü¥Xª«¥óªº¦WºÙ¡A¨Ò¦p¡A­n§ïÅܤ@­Óª«¥óªº¦h­ÓÄÝ©Ê¡A¥i¥H¦b With ±±¨îÅvµ²ºc¤¤¥[¤W«ü©wÄݩʪº³¯­z¦¡¡A³o®É«á¥u­n¦A²Ä¤@¦æ«ü¦Wª«¥ó¦WºÙ¡A¦Ó¤§«áªº«ü©wÄݩʳ¯­z¦¡¤¤´N¤£¥Î¦A¥[¤Wª«¥ó¦WºÙ¡C
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

ÁÂÁª©¥D¡A§ÚÁA¸Ñ¤F¡A³o­Óµ{¦¡¹ï§Ú«D±`¦³À°§U¡A§Ú¤]¥¿¦b¾Ç²ßVBA»yªk¡A§Æ±æ¥H«á¯à¹³ª©¥D¥Î¤Ö¤Ö´X¦æ´N¯à¹F¨ì®ÄªGªº¥\¤O    ÁÂÁÂ
YOYO

TOP

·Q½Ð±Ð¤@¤U¡A¤U­±³o¦æµ{¦¡½X¤@ª½¬Ý¤£À´¡A¯à³Â·Ð¤j¤j¸ÑªR¶Ü¡H¥ýÁÂÁ¤F

mytime = Application.Min(a.Offset(, 4), dic(a & a.Offset(, 1)))

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-1-4 21:26 ½s¿è

¦^´_ 8# yagami12th
mytime = Application.Min(a.Offset(, 4), dic(a & a.Offset(, 1)))
Application.Min:  ¨Ï¥Î¤u§@ªí¨ç¼ÆMin
Offset ÄÝ©Ê¡C ¶Ç¦^ Range ª«¥ó¡A¥Î¥H¥Nªí¬Y­Ó«ü©w°Ï°ì¥H¥~ªº½d³ò °ßŪ¡C
a.Offset(, 4)     ¦P¤@¦C,¥k²¾4Ä檺½d³ò
a.Offset(2, 4)  ¤U²¾2¦C,¥k²¾4Ä檺½d³ò
dic µ{§Ç³]¬°¦r¨åª«¥ó   a & a.Offset(, 1) ->¦r¦ê
dic(a & a.Offset(, 1)) ¦bµ{§Çªº Item ¬°¼Æ¦r

TOP

ÁÀÁÂGBKEE¤j¸Ô¸Ñ¡A­ì¨Óoffset¥i¥H¤£³]©w¦C¡A¦]¬°§Ú¤§«e¬Ý®Ñ³£¥´a.offset(0,4)¡A¾Ç¨ì¤F¡AÁÂÁ¡C

a.Offset(, 4)

TOP

        ÀR«ä¦Û¦b : ¦h°µ¦h±o¡C¤Ö°µ¦h¥¢¡C
ªð¦^¦Cªí ¤W¤@¥DÃD