BHuffXLnovice
Board Regular
- Joined
- May 15, 2015
- Messages
- 54
Hi,
Simply put, I'm trying to put together code that will copy and paste an active cell's data into a specific search box on a webpage.
Here is what I have so far. This opens the webpage but then nothing happens from there. I get an "Object Required" message within excel.
The webpage contains two search boxes. I'm looking to copy and paste the active cell data into the second search box but am unsure how to refer to it. The code that I'm using was found online.
I'm thinking there might be an issue with "Delay 1" and also with how the code refers to the search box but I'm not sure how to resolve this. Any help that can be provided would be appreciated. Thanks!
Simply put, I'm trying to put together code that will copy and paste an active cell's data into a specific search box on a webpage.
Here is what I have so far. This opens the webpage but then nothing happens from there. I get an "Object Required" message within excel.
The webpage contains two search boxes. I'm looking to copy and paste the active cell data into the second search box but am unsure how to refer to it. The code that I'm using was found online.
I'm thinking there might be an issue with "Delay 1" and also with how the code refers to the search box but I'm not sure how to resolve this. Any help that can be provided would be appreciated. Thanks!
Code:
Dim IE As Object
Sub SICsearch()
Application.ScreenUpdating = False
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://siccode.com/en/siccode/list/lookup"
Application.StatusBar = "Submitting"
' Wait while IE loading...
While IE.Busy
DoEvents
ActiveCell.Select
Selection.Copy
Wend
' **********************************************************************
delay 1
IE.Document.getElementById("Search").Value = ActiveCell.Value
delay 1
IE.Document.getElementById("Search").Paste
delay 2
IE.Document.getElementById("Search").Click
'**********************************************************************
End Sub
Private Sub delay(seconds As Long)
Dim endTime As Date
endTime = DateAdd("s", seconds, Now())
Do While Now() < endTime
DoEvents
Loop
End Sub