For mysearchrange = 2 To 3 '設定要尋找的日期
mysearchdate = Sheets("總表").Cells(mysearchrange, 5).Value
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://www.cnyes.com/twstock/a_technical2.aspx"
Do While .Busy Or .readyState <> 4: DoEvents: Loop
With .document
'--------------------輸入要查詢的股票市場
For Each A In .getelementsbytagname("SELECT")
If A.Name = "ctl00$ContentPlaceHolder1$D1" Then
For Each myopt In A.Options
If myopt.innertext = "集中市場" Then
myopt.Selected = True
Exit For
End If
Next
Exit For
End If
Next
'-------------------輸入要查詢的日期範圍
For Each B In .getelementsbytagname("SELECT")
If B.Name = "ctl00$ContentPlaceHolder1$D3" Then
For Each myopt In B.Options
If myopt.innertext = mysearchdate Then
myopt.Selected = True
B.fireEvent ("onchange")
Exit For
End If
Next
Exit For
End If
Next
End With
Do While .Busy Or .readyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:10 AM# '在程式中'等候10秒