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

[µo°Ý] ­ì¥»°õ¦æ¥¿±`¦ý¹j¤Ñ«oÅܲ§±`ªºµ{¦¡½X

[µo°Ý] ­ì¥»°õ¦æ¥¿±`¦ý¹j¤Ñ«oÅܲ§±`ªºµ{¦¡½X

¥»©«³Ì«á¥Ñ smart3135 ©ó 2017-2-25 06:45 ½s¿è

·Q½Ð±Ð¤@¤U¦U¦ì«e½ú¡A¥H¤Uªºµ{¦¡½X¦b¼g¦n·í¤Ñ­ì¥»¥i¥H¥¿±`§ì¨ì¿é¤J¤é´Áªº¸ê®Æ
¦bµ{¦¡½X§¹¥þ¨S¦³Åܧ󪺱¡ªp¤U¡A¹j¤Ñ°õ¦æ®É¿é¤J¸ûªº¤é´Á«o¥u¯à§ì¨ì³Ì·s·í¤Ñªº¸ê®Æ
¦³®É¬Æ¦ÜÁ٧줣¨ì¸ê®Æ¡A¤£ª¾¹D¬O§Ú¹q¸£EXCELª©¥»ªº°ÝÃDÁÙ¬Oµ{¦¡½X¦³°ÝÃD¡H¥i¥H½Ð°ª¤â­ÌÀ°¦£¬Ý¤@¤U¶Ü¡H
«D±`·PÁÂ[attach]26720[/attach]
  1. Option Explicit
  2. Sub ¤W¥«¥~¸ê©M§ë«H()
  3.   Dim X, Y, qdate, select2 As String
  4.   Sheets("¸ê®Æ°Ï").Select
  5.   X = InputBox("½Ð¿é¤J¤ë¥÷")
  6.   Y = InputBox("½Ð¿é¤J¤é´Á")
  7.   qdate = "106" & "/" & X & "/" & Y
  8.   select2 = "ALLBUT0999"

  9.   With ActiveSheet.QueryTables.Add(Connection:= _
  10.     "URL;http://www.twse.com.tw/ch/trading/fund/T86/T86.php", Destination:=Range( _
  11.     "$A$1"))
  12.     .Name = "ÃÒ¥æ©Ò¤T¤jªk¤H¶R½æ¶W¤é³ø"
  13.     .FieldNames = True
  14.     .RowNumbers = False
  15.     .FillAdjacentFormulas = False
  16.     .PreserveFormatting = False
  17.     .RefreshOnFileOpen = False
  18.     .BackgroundQuery = False
  19.     .RefreshStyle = xlOverwriteCells
  20.     .AdjustColumnWidth = False
  21.     .WebSelectionType = xlSpecifiedTables
  22.     .WebFormatting = xlWebFormattingNone
  23.     .WebTables = "2"
  24.     .PostText = "qdate=" & qdate & "&select2=" & select2
  25.     .WebPreFormattedTextToColumns = True
  26.     .WebConsecutiveDelimitersAsOne = True
  27.     .WebSingleBlockTextImport = False
  28.     .WebDisableDateRecognition = True
  29.     .WebDisableRedirections = False
  30.     .Refresh BackgroundQuery:=False
  31.   End With

  32. End Sub
  33. Sub ¤WÂd¥~¸ê¶R½æ¶W()
  34. '¤WÂd¥~¸ê¶R½æ¶W
  35.     Dim X, Y, mydate As String
  36.     X = InputBox("½Ð¿é¤J¤ë¥÷")
  37.     Y = InputBox("½Ð¿é¤J¤é´Á")
  38.     mydate = "106" & "/" & X & "/" & Y
  39.     Sheets("¸ê®Æ°Ï").Select
  40.     With ActiveSheet
  41.         .Cells.Clear
  42.          With .QueryTables.Add(Connection:= _
  43.             "TEXT;http://www.tpex.org.tw/web/stock/3insti/qfii_trading/forgtr_download.php?l=zh-tw&t=D&type=buy&d=mydate&s=0,asc,1" _
  44.                         , Destination:=.Range("$A$1"))
  45.             .TextFileCommaDelimiter = True
  46.             .Refresh BackgroundQuery:=False
  47.             .Delete
  48.         End With
  49.     End With
  50. End Sub
  51. Sub ¤WÂd§ë«H¶R½æ¶W()
  52. '¤WÂd§ë«H¶R½æ¶W
  53.     Dim X, Y, mydate As String
  54.     X = InputBox("½Ð¿é¤J¤ë¥÷")
  55.     Y = InputBox("½Ð¿é¤J¤é´Á")
  56.     mydate = "106" + "/" + "X" + "/" + "Y"
  57.     Sheets("¸ê®Æ°Ï").Select
  58.     Range("a1").Select
  59.     With ActiveSheet
  60.         .Cells.Clear
  61.           With .QueryTables.Add(Connection:= _
  62.             "TEXT;http://www.tpex.org.tw/web/stock/3insti/sitc_trading/sitctr_download.php?l=zh-tw&t=D&type=buy&d=mydate&s=0,asc,1" _
  63.                         , Destination:=.Range("$A$1"))
  64.             .TextFileCommaDelimiter = True
  65.             .Refresh BackgroundQuery:=False
  66.             .Delete
  67.           End With
  68.     End With
  69. End Sub
½Æ»s¥N½X

TEST.zip (19.74 KB)

¦^´_ 1# smart3135

qdate£¾ªº®æ¦¡¦³»~
  1.   qdate = "106" & "/" & Format(X, "00") & "/" & Format(Y, "00")
½Æ»s¥N½X
¬°106/03/01
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD