Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

[SOLVED] VBA code for excluding weekend dates from Web import into Excel

$
0
0
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


Viewing all articles
Browse latest Browse all 50061

Trending Articles