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

[µo°Ý] Ãö©ó¤u§@ªíªºcalculate¨Æ¥ó

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2013-6-15 07:54 ½s¿è

¦^´_ 1# lin_6219
¬Ý¤F§A¼Æ¤éªº°Q½×¦¨ªG¡AÁÙ¬Oµ¹§A­Ó´£¥Ü§a¡A­n¥[ªoËç¡I
«ä¦Ò°ÝÃD­n¦h¤èªºÅçÃÒ¤ÎÆ[¹î¡A¥H´Á¯à¤Á¤J¨ì¯u¥¿ªº°ÝÃD®Ö¤ß¡C
IJµo°õ¦æµe°ÊºAªº¹Ïªí¡G
  1. Option Explicit

  2. Dim timerEnabled As Boolean        '   §P©w¶}±Ò¥»¤u§@ªí³æªº®É¬q¬O§_¬°¶}½L«e±Ò°Ê¡C
  3. Private Sub Workbook_Open()
  4.     KChartWithVolume                        '   ¥H§A¦Û¤vªº K ¹Ï°µ¬°¨ÒÃÒ
  5.     '   ¨C³{¬P´Á¤»¡B¤é °£¥~¡A ¦Û°Ê±Ò°Ê­p®É¾¹
  6.     If Weekday(Date, 2) <= 5 Then Call timerStart
  7. End Sub

  8. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  9.     On Error Resume Next
  10.     Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.inProcess", , False
  11.     Me.Save
  12. End Sub

  13. Sub timerStart()
  14.     If timerEnabled Then
  15.         ' ²Ä¤G¦¸(§t)¥H«á§¡¥H³]©w¤§ "¶¡¹j®É¬q" ¨Ó³B²z°õ¦æ§Çªº§@·~¡C (¥»¨Ò¥H¨C¤­¤ÀÄÁ°õ¦æ¤@¦¸)
  16.         Application.OnTime (Now + TimeValue("00:05:00")), "ThisWorkbook.inProcess"
  17.     Else
  18.         timerEnabled = True
  19.         
  20.         If (TimeValue(Now) <= TimeValue("08:45:00")) Then
  21.             Application.OnTime (TimeValue("08:45:00")), "ThisWorkbook.inProcess"
  22.         Else
  23.             ' ¨t²Î­è³s¤W DDE ¦Ü¸ê®Æ¶×¤JExcel¤u§@ªí³æ¡A¶·¦³¤@­Ó½w½Ä®É¬q¡A
  24.             ' ³o®É¦pªG°¨¤W¥h§ì¨úDDE¸ê®Æ¡A·|¦³«¬ºA¤£²Åªº¿ù»~°T®§²£¥Í¡A¨Ã¤¤Â_°õ¦æ§Çªº§@·~¡C
  25.             Application.OnTime (Now + TimeValue("00:00:05")), "ThisWorkbook.inProcess"
  26.         End If
  27.     End If
  28. End Sub

  29. Private Sub inProcess()
  30.     On Error Resume Next
  31.     If (TimeValue(Now) < TimeValue("08:45:00") Or TimeValue(Now) > TimeValue("13:46:01")) Then Exit Sub
  32.    
  33.     ' ½L¤¤³B²z¡A±N¸ê®Æ¶×¤J¼g¤J¤u§@ªí³æ¤ºÀx¦s¡C

  34.     With Sheets("¥Dµe­±")
  35.         ' . . . . .
  36.         ' . . . . . (¼g¤JDDE¶×¤J¤§¬ÛÃö¸ê®Æ))
  37.         ' . . . . .
  38.     End With
  39.         
  40.     Call getKLastMove()     '  Ä²µo°õ¦æµe°ÊºAªº¹Ïªí
  41.     Call timerStart
  42. End Sub

  43. Sub getKLastMove()
  44.     Dim totalRows As Long
  45.    
  46.     With Worksheets("¥Dµe­±")
  47.         .Select
  48.         totalRows = Worksheets("ø¹Ï¸ê®Æ").Range("A" & .Rows.Count).End(xlUp).Row
  49.         ActiveSheet.ChartObjects.Select
  50.         With ActiveChart
  51.             .SetSourceData Source:=Range("ø¹Ï¸ê®Æ!$A$2:ø¹Ï¸ê®Æ!$E$" & CStr(totalRows) & ", ø¹Ï¸ê®Æ!$G$2:ø¹Ï¸ê®Æ!$G$" & CStr(totalRows) &  _
  52.                                          ", ø¹Ï¸ê®Æ!$F$2:ø¹Ï¸ê®Æ!$F$" & CStr(totalRows))
  53.             .SeriesCollection(1).Name = "=ø¹Ï¸ê®Æ!$B$1"           ' ¶}½L»ù
  54.             .SeriesCollection(2).Name = "=ø¹Ï¸ê®Æ!$C$1"           ' ³Ì°ª»ù
  55.             .SeriesCollection(3).Name = "=ø¹Ï¸ê®Æ!$D$1"           ' ³Ì§C»ù
  56.             .SeriesCollection(4).Name = "=ø¹Ï¸ê®Æ!$E$1"           ' ¦¬½L»ù (¦¨¥æ»ù)
  57.             .SeriesCollection(5).Name = "=ø¹Ï¸ê®Æ!$G$1"           ' ²¾°Ê¥­§¡½u
  58.             .SeriesCollection(5).Name = "¦¨¥æ¶q"                   ' ¦¨¥æª÷ÃB
  59.         End With
  60.     End With
  61. End Sub

  62. Sub KChartWithVolume()                         '  K½u¹Ï»P¦¨¥æ¶q¹Ï©ñ¦b¦P¤@¹Ïªí
  63.     ' . . . . .
  64.     ' . . . . .  (K½u¹Ï»P¦¨¥æ¶q¹Ï)
  65.     ' . . . . .
  66. End Sub
½Æ»s¥N½X
¦h¸ò¾Ç®Õ±Ð±Â¤Î¦P¾Ç­Ì¬Û¤¬½Ð¯q¡C

TOP

¦^´_ 8# lin_6219
­º¥ý­n¥ý¥hÁA¸Ñ¤Î¼ô±x F8 (Debug) ªºÀ³¥Î¡A
³z¹L F8 §A¦A¥h°lÂÜ Local Variables ­ÈªºÅܤơA
¥H¤Î§Q¥Î "ºÊ¬Ý¦¡" µøµ¡ "¹Bºâ¦¡" Æ[¹î¥Ø«e¤§
Runtime Values¡A ¦p¦¹§A¥i¥H±q¤¤¥hÅé·|µ{¦¡
§¹¾ã°õ¦æ¹Lµ{¡B¥H¤Î°ÝÃDµo¥Í¿ù»~ªº­ì¦]¡C

TOP

        ÀR«ä¦Û¦b : ¤f»¡¦n¸Ü¡B¤ß·Q¦n·N¡B¨­¦æ¦n¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD