I have a list of numbers in excel, and I want to automate the process of entering them into a web-page one by one.
The code I currently have logs onto this website, enters username info and password. Presses enter. Then goes to the next screen, where I have it clicking initiate.
Next, it goes to the next screen, where the program clicks the history button. It then goes back to excel (to column A) and takes the first number out and enters it where it says "Number Here", and clicks enter. This brings me to a page with a ton of info that I then, copy and paste back into excel.
Again, I have the program running for these factors.
However, I believe my code should be moving onto the next number in the column (ie, doing the above steps first for cell A3, then for cell A4 etc), but it is not.
Below is my code:
Option Explicit
Sub _NumberFix()
Dim IE As Object
Dim IeDoc As Object
Dim aInput As Object
Dim eInput As Object
Dim svalue1 As Object
Dim elems As Object
Dim t As Date
Dim i As Long, lastrow As Long
Dim ws As Worksheet, wks As Excel.Worksheet
Dim NewName As String
Dim sheet As Worksheet
Dim duplicate As Boolean
Const MAXWAIT_sec As Long = 10
Set ws = Sheets("VALUES")
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.Navigate ("http://mywebsite.com/")
Do While IE.busy: DoEvents: Loop
Set IeDoc = IE.document
'Enters username and password
With IeDoc.all
.UserName.Value = "userr"
.Password.Value = "password"
End With
With IE.document.forms("signingin")
.document.forms(0).submit
End With
Set IeDoc = IE.document ' set new page source
t = Timer
Do
On Error Resume Next
Set elems = IeDoc.queryselector("input[value=Initiate]")
On Error GoTo 0
If Timer - t > MAXWAIT_sec Then
Exit Do
End If
Loop While elems Is Nothing
If Not elems Is Nothing Then
elems.Item.Click
End If
IeDoc.getElementByID("checkConf").Click
For Each aInput In IeDoc.getElementsbyTagName("input")
If aInput.getAttribute("value") = "Request" Then
aInput.Click
Exit For
End If
Next aInput
Do While IE.busy: DoEvents: Loop
'Selects historical
For Each aInput In IeDoc.getElementsbyTagName("input")
If aInput.getAttribute("value") = "History" Then
aInput.Click
Exit For
End If
Next aInput
lastrow = ws.Cells(ws.rows.Count, "A").End(xlUp).Row
IE.Visible = True
For i = 3 To lastrow
Set IeDoc = IE.document ' set new page source
Set svalue1 = IeDoc.getElementByID("Number")
svalue1.Value = ws.Cells(i, 1).Value 'takes the number out and enters
'presses submit once numb is entered
For Each aInput In IeDoc.getElementsbyTagName("input")
If aInput.getAttribute("value") = "Submit" Then
aInput.Click
Exit For
End If
Next aInput
IE.Navigate ("https://mywebsite.com/")
Do While (IE.READYSTATE <> 4 Or IE.busy <> False): DoEvents: Loop
IE.Visible = True
Exit For
Next i
Do While (IE.READYSTATE <> 4 Or IE.busy <> False): DoEvents: Loop
IE.Visible = True
End Sub