Use VBA to pull price information from website.

Tclem

New Member
Joined
Jul 30, 2012
Messages
1
I have had the repetitive task of updating tire prices on an excel spreadsheet from tirerackwholesale.com. It involves copying the manufacturer part number from Cells.(B2:B418), pasting into the website "Part number Search," then copying the "price" to enter back into Cells.(D2:D418). It gets old very quickly. Therefore, I have been trying to code in VBA in order to automate this process for me when I need to update.

My first approach was to hyperlink each part number, and then use the source of that website page and parse it for the price. I was able to get the VBA to find the price for the first part number with the following code:




Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells=Range("B2").Cells Then
Dim IE As New InternetExplorer
IEVisible=False
IE.navigate "http://www.tirerackwholesale.com/tires/TireSearchResults.jsp?Vnum=" &Range("B2").Value

Do
DoEvents
Loop Until IE.readyState=READYSTATE_COMPLETE
Dim Doc As HTMLDocument
Set Doc As HTMLDocument
Set Doc=IE.document
Dim sdd As String
sdd= Trim(Doc.getElementsByTagName("strong") (8).innerText)
Range ("D2").Value=sdd


End If

End Sub






There might be an easier way to code what I already have. I am very new to VBA and am learning as I go. Any help would be greatly appreciated! If this code is the best one for this action, I somehow need to add on a loop to it in order to continue the action through the entire list of 418 "part numbers."

Thanks in advance
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,215,465
Messages
6,124,978
Members
449,200
Latest member
Jamil ahmed

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