- 帖子
- 161
- 主題
- 26
- 精華
- 0
- 積分
- 187
- 點名
- 0
- 作業系統
- xp
- 軟體版本
- office 2010
- 閱讀權限
- 20
- 性別
- 男
- 來自
- TW
- 註冊時間
- 2011-1-2
- 最後登錄
- 2022-2-16
|
6#
發表於 2013-9-17 23:57
| 只看該作者
本帖最後由 GBKEE 於 2013-9-19 08:26 編輯
網址下錯了,再重上載
Private Sub GetDividend(ByVal ss As String)
Dim rr As String
rr = "http://yamstock.megatime.com.tw/asp/stockinfo/GetReport.asp?select_table=html\Ficxxx\&stockid=" & ss & "&name1=D4&index1=12" ' 正確的
工作表2.Select
Cells.Clear
Set ie = CreateObject("internetexplorer.application") '使用此方式可以免除 "設定引用項目"
With ie
.Visible = False 'True為開啟ie, False為不開啟ie
.Navigate rr
Do While .ReadyState <> 4 '等待網頁開啟
DoEvents
Loop
.ExecWB 17, 2 'Select All
.ExecWB 12, 2 'Copy selection
工作表2.Range("A1").Activate
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
End With
ie.Quit
End Sub
Sub AllFile()
Dim i As Integer, v
For i = 2 To 工作表1.Range("A" & 工作表1.Rows.Count).End(xlUp).Row
v = 工作表1.Cells(i, 1).Value
Call GetDividend(v)
工作表1.Cells(i, 9).Value = 工作表2.Cells(34, 8).Value: 工作表1.Cells(i, 10).Value = 工作表2.Cells(33, 8).Value
工作表1.Cells(i, 11).Value = 工作表2.Cells(32, 8).Value: 工作表1.Cells(i, 12).Value = 工作表2.Cells(31, 8).Value
工作表1.Cells(i, 13).Value = 工作表2.Cells(30, 8).Value: 工作表1.Cells(i, 14).Value = 工作表2.Cells(29, 8).Value
工作表1.Cells(i, 15).Value = 工作表2.Cells(28, 8).Value: 工作表1.Cells(i, 16).Value = 工作表2.Cells(27, 8).Value
If 工作表2.Cells(34, 8).Value > 0 And 工作表2.Cells(33, 8).Value > 0 And 工作表2.Cells(32, 8).Value > 0 _
And 工作表2.Cells(31, 8).Value > 0 And 工作表2.Cells(30, 8).Value > 0 And 工作表2.Cells(29, 8).Value > 0 _
And 工作表2.Cells(28, 8).Value > 0 And 工作表2.Cells(27, 8).Value > 0 Then
工作表1.Cells(i, 17).Value = 1
Else
工作表1.Cells(i, 17).Value = 0
End If
Next
End Sub
=================
請問 On Error Resume Next
要用在 FOR NEXT 下方
還是 下方
要判斷是否大於0是要用 AND 還是 &
如果有不是數字的例"-"要如何
謝謝 |
|