1
<tbody>
            <tr>
                <td>
                    <a href="/denmark/1st-division/">1st Division 2016/2017</a>
                </td>
                    <td>
                    </td>
            </tr>
            <tr class="even">
                <td>
                    <a href="/denmark/1st-division-2015-2016/">Bet25 Liga 2015/2016</a>
                </td>
                    <td>

Hi guys! I would like to get this: Bet25 Liga 2015/2016 from that source code.

Sub ExtractHrefClass()

    With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", Range("D8").Value, False
        .Send
        Range("E8").Value = Split(Split(Split(.ResponseText, "<tr class=""even"">", 2)(1), "<a href=""", 2)(1), """", 2)(0)
    End With

End Sub

A friend gave me this macro that allows me to extract the href of that "even" class, but i need to have the InnerText too. where i have to change the code? Thanks :)

Community
  • 1
  • 1
ALIENATO
  • 47
  • 8
  • Please share the URL from `D8` cell. – omegastripes Jan 08 '17 at 23:11
  • @omegastripes http://www.soccer24.com/denmark/1st-division/archive/, today i send you an email my friend ^^ – ALIENATO Jan 08 '17 at 23:21
  • @omegastripes Sorry but i need a thing more, when the macro run an error **(Subscript out of range)** because it not find what it is looking for, i would like to go on with the next macro – ALIENATO Jan 09 '17 at 00:28

1 Answers1

3

Try the below code:

Sub ExtractHrefClass()

    With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", Range("D8").Value, False
        .Send
        a = Split(Split(Split(.ResponseText, "<tr class=""even"">", 2)(1), "<a href=""", 2)(1), """>", 2)
    End With
    Range("E8").Value = a(0)
    Range("F8").Value = Split(a(1), "<", 2)(0)

End Sub
omegastripes
  • 12,351
  • 4
  • 45
  • 96