Help with VBA code

rivrgrl7

New Member
Joined
Mar 22, 2016
Messages
3
I am trying to pull the delivery status of specific ups and fedex shipments into an excel file. The ups portion is working fine, but I am having trouble with Fedex . If anyone has a solution, I would be very grateful. Thank you!


Option Explicit
Sub packageStatus()
Dim ie As New InternetExplorer
ie.Visible = False
Dim Doc As HTMLDocument
Dim rng As Range, cell As Range
Dim celltxt As String
Set rng = Range("B6:b9")
For Each cell In rng
celltxt = cell.Offset(0, 2).Text
If InStr(1, celltxt, "1Z") > 0 Then
ie.navigate "http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&tracknum=" & cell.Offset(0, 2).Value & "&AgreeToTermsAndConditions=yes&track.x=17&track.y=4"
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set Doc = ie.document
Dim uStatus As String
uStatus = Doc.getElementById("tt_spStatus").innerText
cell.Offset(0, 1) = uStatus
Else
ie.navigate "http://www.fedex.com/Tracking?tracknumbers=" & cell.Offset(0, 2).Value & "&cntry_code=us&clienttype=ivother&"
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set Doc = ie.document
Dim fStatus As String
fStatus = Doc.getElementById("container").getElementsByClassName("statusChevron_key_status bogus")
cell.Offset(0, 1) = fStatus
End If
Next cell
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,216,753
Messages
6,132,514
Members
449,731
Latest member
dasda34

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