VBA Code to copy Chrome html doc to excel

Sivas

New Member
Joined
Aug 29, 2018
Messages
20
Can anyone explain, how to copy .htm data to excel. I have the code as below, but it's copying all unwanted data also.

Sub Pull_html()
Dim z As Long, e As Long
Dim f As String, m As String, n As String
Sheets("Sheet1").Select
Cells(1, 1) = "=cell(""filename"")"
Cells(1, 2) = "=left(A1,find(""["",A1)-1)"
Cells(2, 1).Select
f = Dir(Cells(1, 2) & "*.htm")
Do While Len(f) > 0
ActiveCell.Formula = f
ActiveCell.Offset(1, 0).Select
f = Dir()
Loop
z = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For e = 2 To z
n = Sheets("Sheet1").Cells(e, 1)
If n <> ActiveWorkbook.Name Then
If Len(n) < 35 Then
m = Left(n, Len(n) - 4)
Else
m = Left(n, 31)
End If
Sheets.Add.Name = m
With ActiveSheet.QueryTables.Add(Connection:="URL;file:///" & Sheets("Sheet1").Cells(1, 2) & Sheets("Sheet1").Cells(e, 1), _
Destination:=Sheets(m).Range("A1"))
.Name = "goodbites"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = False
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
End If
Next e
MsgBox "collating is complete."
End Sub

In .htm doc the fields looks like

Document And Entity Information (USD $)

6 Months Ended
Jun. 30, 2018Jul. 31, 2018Dec. 31, 2017
Document Information [Line Items]
Document Type10-Q
Amendment Flagfalse
Document Period End DateJun. 30, 2018
Document Fiscal Year Focus2018
Document Fiscal Period FocusQ2
Entity Registrant NameMacquarie Infrastructure Corp
Entity Central Index Key0001289790
Current Fiscal Year End Date--12-31
Entity Filer CategoryLarge Accelerated Filer
Trading SymbolMIC
Entity Common Stock, Shares Outstanding 85,370,832
Common Stock, Par or Stated Value Per Share$ 0.001$ 0.001$ 0.001

<tbody>
</tbody>


I need only the data which is visible in doc. But its copying all extra unwanted data in excel. Could anyone help on this.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top