- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 7# gelai01000001
¸Õ¸Õ¬Ý- Option Explicit
- Sub ¤U¸üºô¯¸¸ê®Æ()
- Dim Startmonth As String, Startday As String, xDate As Date, Msg As Boolean, Sh As Worksheet
- Dim Wb As Workbook, Ws As Worksheet, Stock As Range
- On Error GoTo EX 'µ{¦¡°õ¦æ¤¤¦³¿ù»~®É¸õ¨ì EX: Ä~Äò°õ¦æµ{¦¡
- xDate = Date '·í¤é
- Set Sh = Workbooks.Add.Sheets(1) '·s¬¡¶Ã¯ªº²Ä¤@Ó¤u§@ªí
- EX:
- If Err.Number <> 0 Or Msg = True Then '·í¤é(©|¥¼¦³¸ê®Æ:¿ù»~) ©Î ¥ð¥«
- xDate = xDate - 1 '©¹«á°h¤@¤Ñ¤@ª½¨ì¶}¥«. ( °²¦p¥ð¥«¶W¹L1¤Ñ¥H¤W(2,3,4,5,6,¬K¸`9¤Ñ)
- Err.Clear
- Msg = False
- End If
- Startday = Format(xDate, "YYYYMMDD")
- Startmonth = Format(xDate, "YYYYMM")
- '¤U¸üºô¯¸ªººô§}
- With Sh.QueryTables.Add(Connection:="URL;http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/genpage/Report" & Startmonth & "/A112" & Startday & "ALLBUT0999_1.php?select2=ALLBUT0999&chk_date=" & Format(xDate, "E/MM/DD"), Destination:=Range("A3"))
- .RefreshStyle = xlOverwriteCells '§ì¨úºô¶ªº²Ä10Óªí®æ§@¬°¶×¤J¸ê®Æ
- .WebTables = "10"
- .Refresh BackgroundQuery:=False '·í¤é(©|¥¼¦³¸ê®Æ:¿ù»~)
- If Application.CountA(Sh.QueryTables(1).ResultRange) = 0 Then '¥ð¥« ¨S¦³¸ê®Æ
- Msg = True
- GoTo EX
- End If
- End With
- For Each Wb In Workbooks
- For Each Ws In Wb.Sheets
- Set Stock = Sh.[A:A].Find(Ws.Name, lookat:=xlWhole)
- If Not Stock Is Nothing Then
- Stock.Offset(, 2).Resize(, 14).Copy
- With Ws
- With .Range("a" & .Rows.Count).End(xlUp).Offset(1)
- .Cells = xDate
- .Offset(, 1).PasteSpecial xlPasteValuesAndNumberFormats
- End With
- End With
- End If
- Next
- Next
- Sh.Parent.Close False 'Ãö³¬: ·s¬¡¶Ã¯ªº²Ä¤@Ó¤u§@ªí
- End Sub
½Æ»s¥N½X |
|