Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Re: Dynamic Qurey

Depends what you're trying to accomplish, something like this i'd set up some cells to enter the values I need in, and use that to build the URL I needed for my query.

Something like this

Code:
Sub Macro1()


Dim locstr As String
Dim yearstr As String
Dim daystr As String
Dim monthstr As String


locstr = Sheets("Sheet2").Range("A1").Value
yearstr = Sheets("Sheet2").Range("A2").Value
daystr = Sheets("Sheet2").Range("A3").Value
monthstr = Sheets("Sheet2").Range("A4").Value


With ActiveSheet.QueryTables(1)
    .Connection = "URL;http://www.realtimetrains.co.uk/search/advanced/" & locstr & "/" & yearstr & "/" & daystr & "/" & monthstr & "/0000-2359?stp=WVS&show=all&order=wtt"
    .Refresh
End With


End Sub
 
Upvote 0
Re: Dynamic Qurey

Thanks I will give this ago as it’s what I was looking for to input value in the sheet and return a query from the site.
 
Upvote 0
Re: Dynamic Qurey

I've tried the code but got stuck with A Debug error "With ActiveSheet.QueryTables(1)"
 
Last edited:
Upvote 0
Re: Dynamic Qurey

It will need to be changed to your current query table.

In this case I set up a query table with your current URL, then used that code to change it as the user updates the values.
 
Upvote 0
Re: Dynamic Qurey

Hiya,
I must be something really wrong here to get this working correctly using the code below
and have included in yellow the fields that need to change the URL address before it looks up query and find results.

Lcoation Name:
Sittingbourne Western Junction
CRS Code:
TIPLOC:
STNGWJN
Stanox No:
89028

Realtrains
Day:
28

Month:
09

Year:
2018

<tbody>
</tbody>

It needs to get data from: http://www.realtimetrains.co.uk/sea...18/09/28/0000-2359?stp=WVS&show=all&order=wtt
 
Upvote 0
Re: Dynamic Qurey

Evening,
I must be doing something really wrong with the code as itsnot working for me to change the fields of Location, Date before downloading aQuery from website. I have shared the sheet in Google Drive if somebody canhelp please?

http://www.realtimetrains.co.uk/search/advanced/STNGWJN/2018/09/28/0000-2359?stp=WVS&show=all&order=wtt

Mainsheet highlighted in YELLOW connected with above red

https://drive.google.com/file/d/16ZN55QZtXNPoxBUOGO60rt_F2TbcSKMG/view?usp=sharing
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,142
Members
448,551
Latest member
Sienna de Souza

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