Good Day all is it possible to create a workbook vba that can extract specific data from a website and automatically populate the cells. then choose a date on the site date picker and search for new data and continue the data population?
Sub ExtractDataFromWebsite()
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim datepicker As Object
Dim date_range As Date
Dim row_counter As Integer
' Initialize the date range and row counter
date_range = #1/1/2022#
row_counter = 2
' Create a new HTTP request and send it to the website
Set request = CreateObject("MSXML2.XMLHTTP")
request.Open "GET", "http://www.example.com/data?date=" & date_range, False
request.send
' Parse the HTML response and extract the desired data
response = request.responseText
html.body.innerHTML = response
Cells(row_counter, 1).Value = html.getElementsByClassName("data1")(0).innerText
Cells(row_counter, 2).Value = html.getElementsByClassName("data2")(0).innerText
' Repeat the above two lines of code for each desired data point
' Find the date picker element and select a new date range
Set datepicker = html.getElementById("datepicker")
datepicker.Value = Format(date_range + 7, "mm/dd/yyyy")
' Increment the row counter and date range for the next iteration
row_counter = row_counter + 1
date_range = date_range + 7
' Repeat the above steps for each desired date range
End Sub