sdrloveshim
New Member
- Joined
- May 10, 2016
- Messages
- 4
I'm trying to write a macro to pull up a webpage with a tracking number, return the delivered date, then move to the next tracking code to do the same. I want that to continue down the spreadsheet until there are no more tracking numbers. This can't start at a particular cell every time because it's an on going spread sheet that's added too every week and this will start close the the bottom. For instance this week where I started was cell D2343. It's not finished code, but any suggestions would be helpful. I am fairly new to coding and extremely new to excel VBA so please bear with me.
Public Sub Tracking()
Dim IE As Object
Dim ReturnValue As String
Dim ProUrl As String
Dim RowCount As Integer
Set IE = CreateObject("InternetExplorer.application")
RowCount = 0
Do While Not ActiveCell.Offset(-1, RowCount).Value = ""
ProUrl = "https://www.rrts.com/Tools/Tracking/Pages/MultipleResults.aspx?PROS=" & ActiveCell.Offset(-1, RowCount).Value
With IE
.Visible = False
.Navigate ProUrl
Do Until Not IE.Busy And IE.readyState = 4: DoEvents: Loop
End With
ReturnValue = Trim(IE.document.getElementsByTagName("Span")(16).innerText)
ActiveCell.Offset(, RowCount).Value = ReturnValue
RowCount = RowCount + 1
Loop
IE.Quit
Set IE = Nothing
End Sub
Public Sub Tracking()
Dim IE As Object
Dim ReturnValue As String
Dim ProUrl As String
Dim RowCount As Integer
Set IE = CreateObject("InternetExplorer.application")
RowCount = 0
Do While Not ActiveCell.Offset(-1, RowCount).Value = ""
ProUrl = "https://www.rrts.com/Tools/Tracking/Pages/MultipleResults.aspx?PROS=" & ActiveCell.Offset(-1, RowCount).Value
With IE
.Visible = False
.Navigate ProUrl
Do Until Not IE.Busy And IE.readyState = 4: DoEvents: Loop
End With
ReturnValue = Trim(IE.document.getElementsByTagName("Span")(16).innerText)
ActiveCell.Offset(, RowCount).Value = ReturnValue
RowCount = RowCount + 1
Loop
IE.Quit
Set IE = Nothing
End Sub