Easy Excel Macro (VBA) – Web Scrapping….Download web data

Easy Excel Macro (VBA) – Web Scrapping….Download web data

Download Babyname Data in Excel by Web Scrapping

 

Just copy and paste in VBA Editior…

VBA Code :
Sub babyname()
Dim nextRow As Integer, i As Integer
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
For i = 0 To 6 ‘this is the page range to be captured. At the time there was 52 total.
Application.StatusBar = “Processing Page ” & i
nextRow = ActiveSheet.Cells(Rows.Count, “B”).End(xlUp).Row + 1
With ActiveSheet.QueryTables.Add(Connection:= _
“URL;http://www.bachpan.com/Indian-Girl-Names-E.aspx?page=” & i, _
Destination:=Range(“A” & nextRow))
.Name = “Indian-Boy-Names”
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = “1”
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ThisWorkbook.Save
Next i
Application.StatusBar = False
End Sub

Share this post

Post Comment

4 × two =