assistance with VBA code to retrieve data from website

KarenKFL

New Member
Joined
Mar 17, 2014
Messages
20
I am trying to teach myself VBA to download HTML to Excel. Using webquery doesn't work, possibly because the website retrieves it's data from a json? I have read a lot of questions, answers and explanations, the one thing I continue to not really see is how structurally all the pieces are put together. Would anyone be kind enough to tell me what my next steps are in this code? It's what I want to accomplish in VBA, but I'm still missing parameters. Currently I get a compile error can't assign array and it highlights the "podId".

When I get the above part working, most importantly there is a "show more" button at the bottom of the webpage. I want the data I retrieve to be the whole approx. 30 pages, not the first one. I could find very little info on going about this in my websearch.

Here is my rough code so far.
Code:
Sub CouponsZip77477()


 With CreateObject("MSXML2.XMLHTTP")
    xmlhttp.Open "GET", "http://www.coupons.com/coupons/?zip=77477"
    XML = http.send()
    xmlDoc = xmlhttp.responseXML
            End With

Dim podId() As Integer
Dim brand() As String
Dim summary() As String
Dim details() As String

Set podId() = Range("A1").Offset(1, 0)
Set brand() = Range("B1").Offset(1, 0)
Set summary() = Range("C1").Offset(1, 0)
Set details() = Range("D1").Offset(1, 0)

End Sub
 

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)
This is a revised code. I realized I had the array incorrect, at this point I'm getting an error that an object is missing. Could someone tell me what the function is that I need to put the two parts together to actually get the data from the website? Any pointers or general suggestions or tips would be appreciated.
Code:
Sub CouponsZip77477()

 With CreateObject("MSXML2.XMLHTTP")
    xmlhttp.Open "GET", "http://www.coupons.com/coupons/?zipcode=77477"
    XML = http.send()
    xmlDoc = xmlhttp.responseXML
            End With

Dim podId() As Integer
Dim brand() As String
Dim summary() As String
Dim strCoupons77477() As String
ReDim strCoupons77477(1 To 400) As String


strCoupons77477(0) = "podId"
strCoupons77477(1) = "brand"
strCoupons77477(2) = "summary"
strCoupons77477(3) = "details"

Dim NumRows As Long
Dim NumCols As Long
Set Destination = Range("A1").Resize(NumRows, NumCols).Value = Arr
NumRows = UBound(Arr, 1) - LBound(Arr, 1) + 1
NumCols = UBound(Arr, 2) - LBound(Arr, 2) + 1

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

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