Help with a EXCEL macro, Loops

I need to data mine golf tournament data from a website.

I recorded a macro to do the download, but I need it to loop multiple times

Sub DownloadTournamentData()
' DownloadTournamentData Macro
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;**4504**", Destination _
        .Name = "EventResult.aspx?eventid=**4504**"

        *extraneous code*

    End With
End Sub

I need a loop so I can download eventids from 4504 to 4604 (I want 100 tournaments so the files don’t get really big) but I can’t figure how to insert the loop number into the bolded code.

Thanks for the help.

You might try creating the connection and .Name parts as a variable and then looping the whole thing.

I don’t promise that this code will work as is but hopefully you can adapt it

For Countnum = 4504 To 4604
    UrlName = "URL;" & Countnum
    Eventname = "EventResult.aspx?eventid=" & Countnum
        With ActiveSheet.QueryTables.Add(Connection:=UrlName, Destination:=Range("$A$1"))
            .Name = Eventname
        End With

        extraneous code
Next Countnum

This might work although I haven’t tested the code.

Thanks, I haven’t been able to try it. I will look at it this evening.

Thanks, I got it to work