簡體   English   中英

Excel VBA腳本從預定義的URL列表復制和粘貼數據

[英]Excel VBA Script to Copy and Paste Data from a Predefined List of URLs

我正在為此扯頭發。 我看到了幾乎可以解決這個問題的其他主題,但是它們的方法通常過於具體。 我不需要刮刮刀那么復雜的東西

我的文件A列中有大約64,000個URL。 我希望Excel轉到每個URL,並在加載后復制整個頁面,然后將其粘貼到Excel中。 我希望所有粘貼的數據都在同一工作簿和同一工作表中一個接一個地粘貼。

好吧,這是完成的代碼,如果有人想知道的話。

    Sub Macro3()
'
' Macro3 Macro
'
'
Dim Erw, Frw, Lrw
Drw = 1
Frw = 1
Lrw = Range("A" & Rows.Count).End(xlUp).Row
For Erw = Frw To Lrw

With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;" & Range("A" & Erw).Value, Destination:=Range("G" & Drw))
        .Name = ""
        .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 = "6"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    Drw = Drw + 80
Next Erw

End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM