Hi there, I need help on the below code: the way this should work is I will list shipment #'s on the excel sheet1 and by running the macro it open the web browser go to the website that I list, then it goes to a particular field and add 5%, this macro is currently working but it only works on one shipment # then it stalls. can you please see what need to be modified so it continues with the rest and most importantly I do not want it to open a new browser for every shipment #. if I list 10 shipments it should modify the 10 from the same one initial open browser. tank you very much for your hep.
Sub test()
Dim brs As InternetExplorer
Dim Element As HTMLLinkElement
Set brs = New InternetExplorer
brs.Visible = True
x = 1
Do While Not (Cells(x, 1).Value = "")
brs.Navigate "http://XX.XX.XX.X/BPG/PO/costChange1.cfm?mPOSN=" & Cells(x, 1).Value
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
Set IeDoc = brs.Document
Set htmldoc = IeDoc.getElementsByTagName("INPUT")
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
Application.Wait Now + TimeSerial(0, 0, 3)
For Each htmlinput In htmldoc
If htmlinput.Name = "vCommP" Then
htmlinput.Value = "5"
htmlinput.Click
Exit For
End If
Next htmlinput
For Each htmlinput In htmldoc
If htmlinput.Name = "vFreight" Then
htmlinput.Click
Exit For
End If
Next htmlinput
Application.Wait Now + TimeSerial(0, 0, 3)
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
For Each htmlinput In htmldoc
If htmlinput.Value = "Save" Then
htmlinput.Click
Exit For
End If
Next htmlinput
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
x = x + 1
Loop
MsgBox "Done!"
End Sub
Sub test()
Dim brs As InternetExplorer
Dim Element As HTMLLinkElement
Set brs = New InternetExplorer
brs.Visible = True
x = 1
Do While Not (Cells(x, 1).Value = "")
brs.Navigate "http://XX.XX.XX.X/BPG/PO/costChange1.cfm?mPOSN=" & Cells(x, 1).Value
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
Set IeDoc = brs.Document
Set htmldoc = IeDoc.getElementsByTagName("INPUT")
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
Application.Wait Now + TimeSerial(0, 0, 3)
For Each htmlinput In htmldoc
If htmlinput.Name = "vCommP" Then
htmlinput.Value = "5"
htmlinput.Click
Exit For
End If
Next htmlinput
For Each htmlinput In htmldoc
If htmlinput.Name = "vFreight" Then
htmlinput.Click
Exit For
End If
Next htmlinput
Application.Wait Now + TimeSerial(0, 0, 3)
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
For Each htmlinput In htmldoc
If htmlinput.Value = "Save" Then
htmlinput.Click
Exit For
End If
Next htmlinput
Do
Loop Until brs.readyState = READYSTATE_COMPLETE
x = x + 1
Loop
MsgBox "Done!"
End Sub