Sometimes you may want to obtain data from an online source and import it into a spreadsheet. This is easy to do, using the following statement:
Workbooks.Open Filename:="URL"
This statement opens the website in a spreadsheet, meaning that you can then use the same VBA commands as on any spreadsheet. For example, if you want to obtain a number from the website (for example a stockquote), you can reference the cell containing the number required. In order to find out which cell you must reference in the code, you must first open the website in Excel (using the command above) and find the correct cell in the spreadsheet. Once you have the correct cell reference, you can then automatically open the website in a spreadsheet, store the number in a variable, and then close the website/spreadsheet. Close the website with this statement:
Windows("Website Title").Close savechanges:=False
Note that to determine the Website Title, you must again use the method of opening the website in a spreadsheet; then look at the "file name" (displayed in the Excel header bar at the very top of the window).