Change integer in code line for HTMLDoc.getElementsByClassName

paspuggie48

New Member
Joined
Jun 21, 2011
Messages
35
I'm lost as a bat and lack basic fundamental VBA knowledge but have drafted the code below and would like some advice please.

I have blocked the original line that contains 'rpb-greyhound-1' as this works perfectly, but when I try to increment the integer each time by 1 to 2, 3, 4, 5 or 6 it does not work for the other integers.

I need the line that contains 'rpb-greyhound-1' to start at 1 and increment by 1 until 'rpb-greyhound-6'.

What am I doing wrong? Have I put the for & next loops in the wrong place? Or can I not concatenate ' rpb-greyhound-" & StartRaceNumber & " hover-opacity" ?

VBA Code:
    Dim StartRaceNumber As Integer
    Dim LastRaceNumber As Integer

    XMLReq.Open "GET", DogPageURL, False
    XMLReq.send
   
    If XMLReq.Status <> 200 Then
        MsgBox "Problem" & vbNewLine & XMLReq.Status & " - " & XMLReq.statusText
        Exit Sub
    End If
   
    HTMLDoc.body.innerhtml = XMLReq.responseText
    Set XMLReq = Nothing
   
    LastRaceNumber = 6
   
    For StartRaceNumber = 1 To LastRaceNumber
        Set DogRows1 = HTMLDoc.getElementsByClassName("rpb-greyhound rpb-greyhound-" & StartRaceNumber & " hover-opacity")
'    Set DogRows1 = HTMLDoc.getElementsByClassName("rpb-greyhound rpb-greyhound-1 hover-opacity")
        For Each DogRow1 In DogRows1
            Set DogNameLink1 = DogRow1.getElementsByTagName("a")(0)
            NextHref = DogRow1.getAttribute("href")
            NextURL = DogURL & Mid(NextHref, InStr(NextHref, ":") + 28)
            Debug.Print DogRow1.innerText, NextURL
        Next DogRow1
    Next StartRaceNumber
 

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