Hello,
I am hitting a wall trying to figure out how to edit my VBA script, and was hoping someone can please help. I have the below VBA script which works almost perfectly. However, there are circumstances when the HTML it returns is wrong and does not contain specific values I need, and when that occurs it is because the source URL string is incorrect. The URL string is a number. I need to add an If statement to my script which:
1) checks if the returned HTML contains any of "sampletext1" OR "sampletext2" OR "sampletext3"
2) If No, then increase the URL value by 1000 and run the HTML call again with the increased URL Value. Continue to add 1000 until the text is found in the HTML.
3) If Found, then continue script.
Current VBA:
Next i
Columns("D:D").wraptext = False
End Sub
Many thanks!
I am hitting a wall trying to figure out how to edit my VBA script, and was hoping someone can please help. I have the below VBA script which works almost perfectly. However, there are circumstances when the HTML it returns is wrong and does not contain specific values I need, and when that occurs it is because the source URL string is incorrect. The URL string is a number. I need to add an If statement to my script which:
1) checks if the returned HTML contains any of "sampletext1" OR "sampletext2" OR "sampletext3"
2) If No, then increase the URL value by 1000 and run the HTML call again with the increased URL Value. Continue to add 1000 until the text is found in the HTML.
3) If Found, then continue script.
Current VBA:
VBA Code:
Public Sub getjdtext()
Dim Url As String
Dim Strresponse As Variant
Dim i As Long
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
Dim Sheet As Worksheet
Set Sheet = Sheets("Main")
For i = 2 To FinalRow
Url = Range("C" & i).Value
Dim httpReq As Object
Set httpReq = CreateObject("MSXML2.ServerXMLHTTP.6.0")
With httpReq
.Open "Get", Url, False
.send
Strresponse = .responseText
Debug.Print
Worksheets("Main").Range("D" & i).Value = Strresponse
End With
Next i
Columns("D:D").wraptext = False
End Sub
Many thanks!