Looking to write some VBA in excel to loop through refreshing a web query that has 2 variables I am trying to populate. After doing some digging online I found the following code which appears to have worked for some other users.
Unfortunately when I try to use this code I am getting an error for the first line of the code saying "Run-Time Error '9': Subscript out of range"
I tried changing the name of my web query and then replacing QueryTables(1) with the name I chose and that gave me the same error.
Hoping someone can help troubleshoot this issue as I have searched on google for a half hour or so and haven't been able to figure it out.
With ActiveSheet.QueryTables(1)
.Connection = "URL;" & NewURL
.Refresh
End With
.Connection = "URL;" & NewURL
.Refresh
End With
Unfortunately when I try to use this code I am getting an error for the first line of the code saying "Run-Time Error '9': Subscript out of range"
I tried changing the name of my web query and then replacing QueryTables(1) with the name I chose and that gave me the same error.
Hoping someone can help troubleshoot this issue as I have searched on google for a half hour or so and haven't been able to figure it out.