Board logo

¼ÐÃD: DDE¸ê®Æ§ì¨ú,³v®æÅã¥Ü°ÝÃD [¥´¦L¥»­¶]

§@ªÌ: jackson184    ®É¶¡: 2011-3-30 00:34     ¼ÐÃD: DDE¸ê®Æ§ì¨ú,³v®æÅã¥Ü°ÝÃD

½Ð°Ý¦U¦ì¤j¤j,
¦bDDE¤¤, §Ú»Ý­n¨C10¤ÀÄÁ§ì¨ú¸ê®Æ.
¦ý­n³v®æÅã¥Ü,
·N«ä¦p¤U:
8:45´Á³f¶}½L....²Ä¤@µ§¸ê®Æ
8:55......²Ä¤Gµ§¸ê®Æ
9:05......²Ä¤Tµ§¸ê®Æ
.....¥H¦¹Ãþ±À.
Àɮפ¤,
Sheet1...¬O¨÷°ÓDDE¸ê®ÆÅÜ°Ê.
Sheet2...¨C¤Q¤ÀÄÁ§ì¨ú¸ê®Æ.
³o­n¦p¦ó¼g©O?
§@ªÌ: GBKEE    ®É¶¡: 2011-3-30 12:47

¦^´_ 1# jackson184
¶ÇÀɨӸոÕ
§@ªÌ: jackson184    ®É¶¡: 2011-3-30 23:54

¦^´_ 2# GBKEE


    [attach]5178[/attach]

¥ý·PÁÂGBKEEÀ°¦£,
Àɮפ¤¦³¤T­Ó­¶­±,
²Ä¤@­¶: §Ú­nÆ[¬dWMS«ü¼Æ.
²Ä¤G­¶:§ì¨ú²Ä¤T­¶¨÷°ÓDDE¦^¶Çªº¼Æ¾Ú, »Ý­n³v®æ°O¿ý90¦¸. ¨C10¤ÀÄÁ§ì¨ú¤@¦¸.
²Ä¤T­¶:¨÷°ÓDDE¼Æ¾Ú.

«Ü©êºp, VBA­è¾Ç²ß¤¤, ¬Ý¹L¦U¦ì°Q½×, ÁÙ¤£¤Ó®e©ö¤W¤â,
¦]¬°¬O¤p¾Ç¥Í¸ê®æ, ¨S¿ìªk¤U¸üÀÉ®×.

©ÎªÌ½ÐGBKEE©Î¦U¦ì¤j¤jµ¹­Ó¤è¦V, §Ú¦AºCºC¾Ç²ß, ¦A½Ð¦U¦ìÀˬd.
§@ªÌ: GBKEE    ®É¶¡: 2011-4-1 13:19

¦^´_ 3# jackson184
¦p¹Ï ´¡¤J¤@¼Ò²Õ ±N¤U¦C¨âµ{§Ç¶K¤W

[attach]5197[/attach]
  1. Option Explicit             '¦b¼Ò²Õ¼h¦¸¤¤±j­¢¨C­Ó¦b¼Ò²ÕùتºÅܼƳ£¥²¶·©ú½Tªº«Å§i¡C
  2. Dim Rng As Range            ' ³q¥Î©ó¼Ò²Õ(Module) ¤ºªº¨p¥ÎÅܼÆ
  3. Private Sub AUTO_OPEN()     '¦¹¥¨¶°©óÀɮ׶}±Ò®É·|¦Û°Ê°õ¦æ
  4.     With Sheets("90")
  5.         .UsedRange.Offset(1).Clear                '²M°£ «e¤@¤éªº¼Æ¾Ú
  6.         Set Rng = .Range("A2:A31,F2:F31,K2:K31")  '¼Æ¾Ú¶Ç¦^ªº°Ï°ì,¬°¦h­«½d³ò.
  7.     End With
  8.     If Time < TimeValue("08:45") Then             '¦­©ó¶}½L®É¶¡
  9.         Application.OnTime TimeValue("08:45"), "MyDee"    '³]©w©ó08:45 °õ¦æ MyDee µ{§Ç
  10.     ElseIf Time >= TimeValue("08:45") And Time <= TimeValue("13:30") Then '©ó¥æ©ö®É¶¡¤º
  11.         MyDee                                     ' °õ¦æ MyDee µ{§Ç
  12.     End If
  13. End Sub
  14. Private Sub MyDee()
  15.     Dim A As Integer, Ar(), R As Integer, C As Integer
  16.      If Time > TimeValue("13:30") Then Exit Sub     ' ¦¬½L®É¶¡«á °±¤î°õ¦æ
  17.     A = Application.CountA(Rng)             '­pºâ (¼Æ¾Ú¶Ç¦^ªº°Ï°ì)¦³¸ê®ÆÀx¦s®æªºÁ`¼Æ
  18.     If A <= 29 Then C = A + 1               'C ¬°  ¼Æ¾Ú¶Ç¦^ªº°Ï°ìªº¦C¦ì
  19.     If A Mod 30 >= 0 Then C = (A Mod 30) + 1
  20.     R = Int(A / 30) + 1                     'R ¬°¦h­«½d³òªº²Ä´X­Ó½d³ò
  21.     With Sheets("³sµ²")
  22.         Ar = Array(Now, A + 1, .Range("I2"), .Range("J2"))
  23.         'Ar ¬°¨ú±o  1. ®É¶¡, 2.¶µ¦¸,3.³Ì°ª»ù ,4,³Ì§C»ù  '§ä¤£¨ì ->  ¦¬½L»ù§ä¤£¨ì
  24.         'Ar = Array(Now, A + 1, .Range("I2"), .Range("J2"), ¦¬½L»ù ) '¦³¦¬½L»ù
  25.     End With
  26.     Rng.Areas(R).Cells(C).Resize(1, 4) = Ar
  27.     'Rng.Areas(R).Cells(C).Resize(1, 5) = Ar   '¦³¦¬½L»ù
  28.     Application.OnTime Now + TimeValue("00:10"), "MyDee"  '³]©w 10¤À«á °õ¦æ MyDee µ{§Ç
  29. End Sub
½Æ»s¥N½X

§@ªÌ: FAlonso    ®É¶¡: 2011-4-1 15:28

½Ð°Ý³o­Ó¨Ò¤l­n¦w¸Ë¤°»òÃB¥~³n¥ó¤~¯à¹B¦æ?
§@ªÌ: GBKEE    ®É¶¡: 2011-4-1 16:49

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-4-1 16:52 ½s¿è

¦^´_ 5# FAlonso
¼Ó¥D¬O¥Î¬Ý½L³nÅ骺
¸Õ¸Õ¬Ý,¥i¿ï¾ÜªÑ²¼,10¬í¬ö¿ý¤@¦¸.

[attach]5200[/attach]
§@ªÌ: FAlonso    ®É¶¡: 2011-4-1 21:24

¦^´_ 6# GBKEE
ÁÂÁ¦^ÂÐ,¤£¹L¦³´XÂI°ÝÃD
¦]¬°GBKEE¤j¤j¨S¦³¼gend if,Ū°_¨Ó¦³ÂI¤£ºD
µ{¦¡¬O§_«ü
  1. If Time > TimeValue("13:30") Then
  2. Exit Sub
  3. End If
  4. ...
  5. ...
  6. ...

  7. If InStr(.ResultRange.Rows(3).Cells(1), stockcode) = 0 Then  
  8. GoTo refresh_err:
  9. Else

  10. Application.EnableEvents = False

  11. Set myrange = mysheet.Range("a65536").End(xlUp).Offset(1).Resize(1, .ResultRange.Columns.Count - 1)
  12. myrange.Value = .ResultRange.Rows(3).Value

  13. Application.EnableEvents = True

  14. myrange.Select

  15. End If
  16. End With

  17. Application.OnTime Now + TimeValue("00:00:10"), "myprogram"

  18. exit sub   ³o­Óexit sub¬O¹ïÀ³¤°»ò

  19. refresh_err:
  20. MsgBox "Stock " & stockcode & " cannot be found"

  21. End Sub
½Æ»s¥N½X

§@ªÌ: jackson184    ®É¶¡: 2011-4-2 14:40

¥»©«³Ì«á¥Ñ jackson184 ©ó 2011-4-2 15:26 ½s¿è

¦^´_ 4# GBKEE


    ÁÂÁÂGBKEE¤j¤j,
¦]¬°§ÚÁÙ¬O¤p¾Ç¥Í,
ÁÙ¤£¯à¤U¸ü±zªº½d¨Ò.
§Ú¦A¸Õ¬Ý¬Ý, ¤£À´¦A½Ð±Ð±z.
§@ªÌ: GBKEE    ®É¶¡: 2011-4-2 16:06

¦^´_ 8# jackson184
¨Ì¹Ï¤ù¦b§Aexcelªº vbaµøµ¡ ´¡¤J¤@¼Ò²Õ
¦^¨ì ½×¾Â  ¦p¹Ï
  «ö¤U ¡u½Æ»s¥N½X¡v«á·|Åã¥Ü [¥N½X¤w½Æ»s¨ì°Å¶Kï] ªº«H®§ ,¦^¨ì vbaµøµ¡¶K¤W§Y¥i

[attach]5218[/attach]



¦^´_ 7# FAlonso
If Time > TimeValue("13:30") Then
Exit Sub
End If
'''''''''''''''''''''''''''''''''''''''''
If Time > TimeValue("13:30") Then  Exit Sub
¦¹¬°Â²¤Æ ³£¬O¥i¹F¨ì¤@¼Ëªº®ÄªG
§@ªÌ: FAlonso    ®É¶¡: 2011-4-2 16:47

¦^´_ 9# GBKEE
ÁÂÁÂ
§Ú¥t¥~¦b"¬ö¿ý"¤@­¶¥[¤F¥H¤Uµ{¦¡
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. If Target.Count > 1 Or Target.Address <> "$C$1" Then
  3. Exit Sub
  4. Else
  5. Sheet2.Range("A3:K65536").Clear
  6. myprogram  '©MmyDEEªºµ{¦¡¤@¼Ë
  7. End If
  8. End Sub
½Æ»s¥N½X
­ì·N¬O·Q·íC1®æ¤lªÑ²¼½s¸¹ÅÜ°Ê®É,²MªÅ"¬ö¿ý"ªº¸ê®Æ¥H¤Þ¤J·sªÑ²¼°T®§
¦³¤@ÂI¤p°ÝÃD,·í¸ÓªÑ²¼½s¸¹¤£¦s¦b®É,·|¤Þµo¨â¦¸"¨S¦³¸ÓªÑ²¼"ªºmsgbox
²z½×¤WÅã¥Ümsgbox«áÀ³¸Ó¤°»ò¤]¤£°Ê,¤£¹Lµ{¦¡«oÃB¥~³s½u¦Üweb,µM«á¦A°õ¦æmsgbox
§Ú¥ÎF8³v¦æµ{¦¡°õ¦æ¤]¥uÅã¥Ü¤@¦¸¦Ó¤w
¤£ª¾¦³¦ó¸Ñ¨Mªk?
§@ªÌ: GBKEE    ®É¶¡: 2011-4-2 20:41

¦^´_ 10# FAlonso
Private Sub MyDee()
    Dim Sh As Worksheet, Rng As Range, ¥N¸¹ As String
    Static Run_Time As Date            'Static ³¯­z¦¡«Å§iªºÅܼơA¦bµ{¦¡°õ¦æ´Á¶¡¡A·|¤@ª½«O¯d¤º®e
  ' If Time > TimeValue("13:30") Then Exit Sub     ' ¦¬½L®É¶¡«á °±¤î°õ¦æ
    Set Sh = Sheets("¬ö¿ý")
    ¥N¸¹ = Sheets("¬ö¿ý").[C1]
    Sh.Activate
    With Sheets("¶×¤J").QueryTables(1)
        .Connection = "URL;http://tw.stock.yahoo.com/q/q?s=" & ¥N¸¹
       .Refresh False
        If InStr(.ResultRange.Rows(3).Cells(1), ¥N¸¹) = 0 Then GoTo Refresh_Err:
       Application.EnableEvents = False
        Set Rng = Sh.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(1, .ResultRange.Columns.Count - 1)
        Rng.Value = .ResultRange.Rows(3).Value
        Application.EnableEvents = True
        Rng.Select
    End With
    Run_Time = Now + TimeValue("00:00:10")
    Application.OnTime Run_Time, "MyDee"  '³]©w 10¬í«á °õ¦æ MyDee µ{§Ç
    Exit Sub
Refresh_Err:
    On Error Resume Next
    Application.OnTime Run_Time, "MyDee", , False  '²M°£¥ý«e³]©wªºµ{§Ç
    MsgBox "§ä¤£¨ì " & Sheets("¬ö¿ý").[C1] & " ªÑ²¼"
End Sub
§@ªÌ: FAlonso    ®É¶¡: 2011-4-3 12:27

¦^´_ 11# GBKEE
¦hÁ¸ѵª,¦ý¬°¤°»ò­n°µ³o¼Ëªº°Ê§@?
(1) ·íinstr(........,¥N¸¹) = 0,µ{¦¡·|¸õ¨ì³Ì«árefresh_err¦Ó¤£·|°µ¦¨­«·s©I¥smydee,²{¦b«o­n¯S·N¥s°±?
(2) static¤@¦r,ªí­±¬Ý¨ä¹ê¥Î©M¤£¥Î¤]¨S¤À§O. ¦]¬°­«ÂйB¦æ, run_timeªº­È¬Onow+timevalue("00:00:10"),§¹¥þ¤£»ÝÄ~©Órun_time¤§«eªº¼Æ­È; ¤£­«ÂйB¦æ,«K·|¬Oapplication ontime 0:00:00,mydee,,false,¤]¤£¥Î«e­±ªº­È. ¦ý¬O¤£¥Îstatic,´N¬O·|¥X²{°ÝÃD.
§Úªº²z¸Ñ¨s³º¨º¸Ìµo¥Í°ÝÃD?
§@ªÌ: GBKEE    ®É¶¡: 2011-4-3 14:33

1 ¦b³oºô­¶¬d¸ßªÑ²¼ªº¥N¸¹,InStr(.ResultRange.Rows(3).Cells(1), ¥N¸¹), ¬°¤ñ¹ï ¶×¤Jªº¸ê®Æ¬O§_¥]§tªÑ²¼ªº¥N¸¹  ·í¦¹¨ç¼Æ¬°0 ®Éªí¥Ü¨S¦³³o­ÓªÑ²¼¥N¸¹
2 ¤£¥Îstatic,´N¬O·|¥X²{°ÝÃD...
  ¤£¥Îstatic,¥i¦b¼Ò²Õ³Ì¤W¤è Dim Run_Time As Date  ³]¬° ¼Ò²Õªº¨p¥ÎÅܼÆ.
§@ªÌ: lin    ®É¶¡: 2011-4-16 22:52

§Ú¬O¤@­Ó·~¾lªÑ²¼±Ú,¦bºô¸ô¤W¤U¸ü¤@¨Ç¦³ÃöªÑ²¼ªºExcelµ{¦¡,Á`ı±o¤£§¹¥þ²Å¦X­Ó¤H»Ý¨D,©Ò¥H¦³ªÅ§Ú·|­×§ï©Î¥[±j¤U¸üµ{¦¡,¨Ñ­Ó¤H¨Ï¥Î,¦ý¦]©ÈIJ¥Ç´¼¼z°]²£Åv,©Ò¥H¤£´±°e¥L¤H¨Ï¥Î,¤]¤£´±¦bºô¸ô¤W¤½¶}.




Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)