VBA Macro question

Moeses

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

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top