Extract Historical COVID 19 Data from Worldometers Site with VBA

  • Hi,


    I have been tracking all of the COVID 19 data for the US and my particular state since very early this year and especially as of recently, I have found it to be very time consuming because it seems like every couple of days, the reported number of total cases, active cases, and deaths for the country will change for days that were previously reported making it a hassle to have to go back and confirm the data for every day I've already entered. I am using two different websites to get my data, https://www.worldometers.info/coronavirus/country/us/ for my US historical data and https://covidtracking.com/data/state/connecticut for my particular state's historical data. Coming up with the code to pull up the website for my state, find the historical data table and pull the data was relatively easy because they have the data set up exactly as that, in tables.


    Worldometers on the other hand, has a single table at the top of the page which has two hyperlinks or tabs basically which show the current day and previous day's data for each state. For the historical data, the site displays the data on a series of interactive charts which allow the user to view the highlighted day's data by hovering over the data point with their cursor. Because this is not a table, I have having trouble with trying to figure out how to extract the individual data points like I was able to do from the table in my state's historical data. I have provided a screenshot which shows both how the data is displayed when a user hovers over a particular data point as well as the respective HTML code for that data point. I'm not sure if there is a way to scrape all of the data together and then I can go through and organize/analyze it how I want to or if I am better off trying to scrape each individual point separately. I am relatively new to HTML scraping so I apologize in advance if I don't say something as clear as you would like and I can gladly try and explain things differently.


  • I have used Power Query to extract the US data from the worldmeters web site. Attached is my workbook which is updated when I click on Refresh All. On the second page, I have built a parameter that allows me to select a particular state for updated information. I have been using this method to track Covid cases for at least the past three months.

  • Hi Alan, first of all, thank you for your reply! I looked into using a Power Query (something I had never heard of before Saturday) as it was a technique that was posted on another forum. Unfortunately, a Power Query won't work for what I am trying to do. The Power Query tool will only grab tables from the given website which is ok if all you want to do is look at the current numbers. In my case, I care about all the historical data which unfortunately is changing every couple of days it seems so the single day historical data that you may have gotten for a week ago, probably isn't correct anymore, unless all you're doing is just refreshing and looking at the current day and then you don't care about where you were on other days. What I need to be able to do is find a way to get the historical data off of the charts listed below the tables of the current day's and yesterday's data which as far as I can tell, they only provide you with a few sources of where the data comes from but not the data that makes up the charts and I have not been able to figure out how to extract the data from the charts themselves.

  • After a little hunt...and an accidental mouse click...I have found where worldometers is keeping their data for the historical charts!!! For anyone who is interested, the data can be accessed by telling your macro to look through worldometers HTML for any script tags. I have used the following which gives me access to the data that I need

    All I have left to do now is just clean it up a bit more.