Why does my InStr function return 0 when it clearly is part of the HTML string?
I cannot post this without more text.I cannot post this without more text.I cannot post this without more text.I cannot post this without more text.I cannot post this without more text.I cannot post this without more text.
Sub ImportBPlans()
Dim BPlan As String, FullHTML As String, URL1 As String, Cut1 As String, T1 As String
Dim FO As String, LO As String, Other1 As Long
For i = 2 To LastRow
T1 = WB1.Cells(i, 1).Value
URL1 = "http://finance.yahoo.com/q/pr?s=" + T1 + "+Profile"
FullHTML = GetHTML(URL1)
BPlan = " </th></tr></table><p>"
x = Len(FullHTML)
FO = InStr(FullHTML, BPlan, CompareMethod.Text) + Len(BPlan)
LO = InStr(FO, FullHTML, "<")
Cut1 = Left(FullHTML, LO)
Cut1 = Right(Cut1, FO - LO)
WB5.Cells(i, 1).Value = Cut1
Next i
End Sub
Function GetHTML(URL As String) As String
Dim HTML As String
Dim htmlBDY As New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
htmlBDY.body.innerHTML = .responseText
GetHTML = htmlBDY.body.outerHTML
End With
End Function
FO and LO are defined as
string
. it should beinteger
as Instr returnsinteger
. Get it corrected.Try this: