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

[µo°Ý] ¦p¦ó¥i¥H«ü©w¤é´Á«á¤U¸ü¸ê®Æ

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-12-9 15:53 ½s¿è

¦^´_ 1# pupai
¨C¤@ºô­¶ªº¤¸¯À·|¦³©Ò¤£¦P.
  1. Option Explicit
  2. Sub ¥~¸ê¤Î³°¸ê¶R½æ¶W·JÁ`ªí()
  3.     Dim URL As String, xDate As Date
  4.     xDate = Format(Date-1, "E/M/D")
  5.     URL = "URL;http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U.php?qdate=" & xDate
  6.     With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=ActiveSheet.Range("a1"))
  7.         .WebSelectionType = xlSpecifiedTables
  8.         .WebFormatting = xlWebFormattingNone
  9.         .WebTables = "5"
  10.         .WebPreFormattedTextToColumns = True
  11.         .WebConsecutiveDelimitersAsOne = True
  12.         .WebSingleBlockTextImport = False
  13.         .WebDisableDateRecognition = False
  14.         .WebDisableRedirections = False
  15.         .Refresh BackgroundQuery:=False
  16.     End With
  17. End Sub
  18. Sub §ë«H¶R½æ¶W·JÁ`ªí()
  19.     Dim URL As String, xDate As Date
  20.     xDate = Format(Date-1, "E/M/D")
  21.     URL = "URL;http://www.twse.com.tw/ch/trading/fund/TWT44U/TWT44U.php?qdate=" & xDate
  22.     With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=ActiveSheet.Range("D4"))
  23.         .Connection = URL
  24.         .WebSelectionType = xlSpecifiedTables
  25.         .WebFormatting = xlWebFormattingNone
  26.         .WebTables = "5"
  27.         .WebPreFormattedTextToColumns = True
  28.         .WebConsecutiveDelimitersAsOne = True
  29.         .WebSingleBlockTextImport = False
  30.         .WebDisableDateRecognition = False
  31.         .WebDisableRedirections = False
  32.         .Refresh BackgroundQuery:=False
  33.     End With
  34. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-12-9 18:32 ½s¿è

¦^´_ 3# pupai
  1. Option Explicit
  2. Sub ¥~¸ê¤Î³°¸ê¶R½æ¶W·JÁ`ªí()
  3.     Dim URL As String, xDate As Date
  4.     xDate = Date - 1   '¸g¬d: ¥~¸ê¤Î³°¸ê¶R½æ¶W·JÁ`ªí ´£¨Ñ«e¤@Àç·~¤éªº¸ê®Æ
  5. ReDate:
  6.     URL = "URL;http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U.php?qdate=" & Format(xDate, "E/M/D")
  7.     With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=ActiveSheet.Range("a1"))
  8.         .WebSelectionType = xlSpecifiedTables
  9.         .WebFormatting = xlWebFormattingNone
  10.         .WebTables = "5"
  11.         .WebPreFormattedTextToColumns = True
  12.         .WebConsecutiveDelimitersAsOne = True
  13.         .WebSingleBlockTextImport = False
  14.         .WebDisableDateRecognition = False
  15.         .WebDisableRedirections = False
  16.         .Refresh BackgroundQuery:=False
  17.         If Application.CountA(.ResultRange) = 0 Then '«DÀç·~¤é,¨S¦³¸ê®Æ.
  18.             xDate = xDate - 1                        '©¹«á°h¤@¤é
  19.             GoTo ReDate
  20.         End If
  21.     End With
  22. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¬Ý§O¤H¤£¶¶²´¡A¬O¦Û¤v­×¾i¤£°÷¡C
ªð¦^¦Cªí ¤W¤@¥DÃD