I have worked through this code I have created and it seem like i'm running into some problems. The code works fine when you manually step into the code and run it, but each time I try to run the code automatically with a macro button I run into a problem.
I receive a Run-time error '70': permission denied. i'm not to sure why the code is tripping up and throwing this code when I run it automatically.
The idea is to be able to type in a town and state in excel and it will search the two websites for data.
I have attached the code below
'start a new subroutine called SearchBot
Sub SearchBot1()
'dimension (declare or set aside memory for) our variables
Dim objIE As InternetExplorer 'special object variable representing the IE browser
Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element
Dim HTMLinputs As MSHTML.IHTMLElementCollection
Dim y As Integer 'integer variable we'll use as a counter
Dim result As String 'string variable that will hold our result link
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
'objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "https://www.zillow.com/orange-county-ny/home-values/"
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'in the search box put cell "A2" value, the word "in" and cell "C1" value
objIE.document.getElementById("local-search").Value = _
Sheets("Sheet2").Range("B3").Value & ", " & Sheets("Sheet2").Range("B4").Value
'click the 'go' button
Set HTMLinputs = objIE.document.getElementsByTagName("button")
For Each input_element In HTMLinputs
If input_element.getAttribute("name") = "SubmitButton" Then
input_element.Click
Exit For
End If
Next input_element
'wait again for the browser
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'price for home
Set Doc = objIE.document
Dim cclass As String
cclass = Trim(Doc.getElementsByClassName("value-info-list")(0).Children(0).innerText)
'MsgBox (cclass)
Dim aclass As Variant
aclass = Split(cclass, " ")
Range("Market_Price").Value = aclass(0)
'1-YR Forecast
cclass = Trim(Doc.getElementsByClassName("value-info-list")(0).Children(1).innerText)
'MsgBox (cclass)
Dim bclass As Variant
bclass = Split(cclass, " ")
Range("yr_forecast").Value = bclass(0)
'Median List Price
cclass = Trim(Doc.getElementsByClassName("value-info-list")(0).Children(2).innerText)
'MsgBox (cclass)
Dim dclass As Variant
dclass = Split(cclass, " ")
Range("Median_List_Price").Value = dclass(0)
'Median Sale Price
cclass = Trim(Doc.getElementsByClassName("value-info-list")(0).Children(3).innerText)
'MsgBox (cclass)
Dim eclass As Variant
eclass = Split(cclass, " ")
Range("Median_Sale_Price").Value = eclass(0)
'Health of market
cclass = Trim(Doc.getElementsByClassName("value-info-list")(1).Children(0).innerText)
'MsgBox (cclass)
Dim fclass As Variant
fclass = Split(cclass, " ")
Range("Healthy").Value = fclass(0)
' Home with Negative Equity
cclass = Trim(Doc.getElementsByClassName("value-info-list")(1).Children(1).innerText)
'MsgBox (cclass)
Dim gclass As Variant
gclass = Split(cclass, " ")
Range("Home_With_Negative_Equity").Value = gclass(0)
'Delinquent on Mortgage
cclass = Trim(Doc.getElementsByClassName("value-info-list")(1).Children(2).innerText)
'MsgBox (cclass)
Dim hclass As Variant
hclass = Split(cclass, " ")
Range("Delinquent_On_Mortgage").Value = hclass(0)
'Listings with price cut
cclass = Trim(Doc.getElementsByClassName("value-info-list")(2).Children(2).innerText)
'MsgBox (cclass)
Dim iclass As Variant
iclass = Split(cclass, " ")
Range("Price_Cut").Value = iclass(0)
'Breakeven Horizon
cclass = Trim(Doc.getElementsByClassName("value-info-list")(3).Children(2).innerText)
'MsgBox (cclass)
Dim jclass As Variant
jclass = Split(cclass, " ")
Range("Breakeven").Value = jclass(0)
'Rent List Price
cclass = Trim(Doc.getElementsByClassName("value-info-list")(3).Children(3).innerText)
'MsgBox (cclass)
Dim kclass As Variant
kclass = Split(cclass, " ")
Range("Rent_List_Price").Value = kclass(0)
'Rent List Price/sq ft
cclass = Trim(Doc.getElementsByClassName("value-info-list")(3).Children(4).innerText)
'MsgBox (cclass)
Dim lclass As Variant
lclass = Split(cclass, " ")
Range("Rent_sq").Value = lclass(0)
'close the browser
objIE.Quit
Set ws = ThisWorkbook.Worksheets("Engine")
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
'objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "https://datausa.io/profile/geo/" & ws.Range("City_Search").Value & "-" & ws.Range("State_Search").Value
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
Set Doc = objIE.document
Dim Data As String
Data = Trim(Doc.getElementsByClassName("stat")(0).Children(1).innerText)
'MsgBox (Data)
Dim adata As Variant
adata = Split(Data, "")
ws.Range("Population").Value = adata(0)
End Sub
'exit our SearchBot subroutine
If anyone can help me out that would be appreciated. I will continue to problem solve to see if I can get it to work. If you have any questions about the formula please ask.
Thank you



