I have adapted the code below from another thread on this forum to extract web data into excel. I would like further advice on how to incorporate a month and year variable to exclude weekend dates. I have also added the four lines of code after “End With”. Can this be improved? I read somewhere that .Select should be avoided? Thanks. vk.
Code:
Sub NoWeekendWebQuery()
Dim i As Integer
For i = 1 To 31
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://hbmarkets.moneyam.com/broker-views/index/date/" & Format(i, "00") & "-01-2013", _
Destination:=ActiveCell)
.Name = "01-10-2012"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Selection.EntireRow.Insert
Selection.EntireRow.Delete
ActiveCell.SpecialCells(xlLastCell).Select
Selection.End(xlToLeft).Select
Next i
End Sub