Convert HTML-table to Excel
The code below fetches the HTML-table at https://rasmusrhl.github.io/stuff, and converts it to Excel-format.
The pr
With the url https://rasmusrhl.github.io/stuff
, it's by luck that Excel can simply just open it directly and save as .xlsx (how come no one try this before the tedious process). If direct open fails, all other methods here are great option!
Option Explicit
Sub OpenWebFile()
Const URL As String = "https://rasmusrhl.github.io/stuff"
Dim oWB As Workbook
On Error Resume Next
Set oWB = Workbooks.Open(Filename:=URL, ReadOnly:=True)
If oWB Is Nothing Then
MsgBox "Cannot open the url " & URL, vbExclamation + vbOKOnly, "ERR " & Err.Number & ":" & Err.Description
Err.Clear
Else
' Change to your desired path and filename
oWB.SaveAs Filename:="C:\Test\stuff.xlsx", FileFormat:=xlOpenXMLWorkbook
Set oWB = Nothing
End If
End Sub