VBA Macro question

Moeses

New Member
Joined
Mar 21, 2019
Messages
1
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
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Watch MrExcel Video

Forum statistics

Threads
1,095,950
Messages
5,447,515
Members
405,454
Latest member
Minglee

This Week's Hot Topics

Top