PDA

View Full Version : VB error while running the project



joseph
03-21-2013, 08:44 PM
I am trying and newie for VBA code.I am trying to grab the data from aussiewebdotcomdotau in the excel list as company name, address and contact with state for the businesses.

I have copied the vba code with some changes.Pls assist

error in : erow = Sheet1.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row
--------------------------------

Sub aussiweb()
Dim erow As Long
Dim ele As Object
Set sht = Sheets("Sheet1")
RowCount = 1
sht.Range("A" & RowCount) = "Sno"
sht.Range("B" & RowCount) = "Company"
sht.Range("C" & RowCount) = "Address"
sht.Range("D" & RowCount) = "Contact"
sht.Range("E" & RowCount) = "State"
sht.Range("F" & RowCount) = "Website"
sht.Range("G" & RowCount) = "Email"
erow = Sheet1.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row
Set objIe = CreateObject("GoogleChrome.Applications")
what = InputBox("Enter type of categories such as roofing,cleaning")
where = InputBox("Enter locations such as wa,all states")
With objIe
.Visible = True
.navigate ""
Do While .Busy Or .READYSTATE <> 4
DoEvents
Loop
Set what = .document.getElementsbytagname("q")
what.Item(0).Value = what
Set where = .document.getElementsbytagname("where")
where.Item(0).Value = where.document.getElementsbyID("Search").Click
Do While .Busy Or .READYSTATE <> 4
DoEvents
Loop
For Each ele In .document.all
Select Case ele.classname
Case "Result"
RowCount = RowCount + 1
Case "Sno"
sht.Range("A" & RowCount) = ele.innertext
Case "Company"
sht.Range("B" & RowCount) = ele.innertext
Case "Address"
sht.Range("C" & RowCount) = ele.innertext
Case "Contact"
sht.Range("D" & RowCount) = ele.innertext
Case "State"
sht.Range("E" & RowCount) = ele.innertext
Case "Website"
sht.Range("E" & RowCount) = ele.innertext
Case "Email"
End Select
Next ele
End With
Set objIe = Nothing
End Sub