Run Time Error 1004 on Do While Not ActiveCell.Offest(-1, RowCount).Value = ""

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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I did previously have ActiveCell.Select just above ProURL = but I'm not sure it make a difference and it still returns the same error.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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