I currently have the following macro to load a webpage:
Sub OOS_Query()
'This together with the True value at the end will tell the macro to not update the screen until it reaches a point that I want it to show updates again
Application.ScreenUpdating = False
ActiveWorkbook.Connections("Connection1").Delete
Sheet2.Range("A:C").Clear
With Sheet2.QueryTables.Add(Connection:= _
"URL;http://[ommitted on purpose]id=42908", Destination:=Sheet2.Range("$A$1"))
.FieldNames = True
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.RefreshPeriod = 5
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1,2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=True
End With
Application.ScreenUpdating = True
End Sub
As you can see the webpage has an "id" value that is constantly changing as it queries a database. That value looks as follows on the source of the webpage:
Date <select name="id">
<option value='43032' >2017-05-13 05:00:01</option>
<option value='43031' >2017-05-13 04:45:02</option>
<option value='43030' >2017-05-13 04:30:01</option>
<option value='43029' >2017-05-13 04:15:02</option>
...
<option value='43004' >2017-05-12 22:00:01</option>
I am looking for a way to integrate in the code to be able to pull the website with whatever id it has, as long as the time is between 21:58:00 and 22:02:00; for whatever the current date is. The way this is normally done is by accessing the website and selecting out of a drop down menu the date/time that we want to query and then copy pasting the website into the section of the code above.
If I could make it do that automatically, it will remove me having to edit the code everyday.
Thanks in advance!