返回列表 上一主題 發帖

QueryTables重複查詢,如何覆蓋上一筆查詢

QueryTables重複查詢,如何覆蓋上一筆查詢

各位大大安安
我使用QueryTable作查詢時,
每次查詢一個股價資料
就會把前一個已經查好的股價資料往旁邊擠
到最後儲存格就會用罄
我希望的是每次查詢都使用同一個範圍的儲存格,
意即把上一個查好的股價資料覆蓋(不要往旁邊擠)
我該怎麼修改呢?
程式碼如下
            With ActiveSheet.QueryTables.Add(Connection:="URL;https://tw.finance.yahoo.com/q/q?s=" & stockID, Destination:=Sheets(10).Range("A1"))
                .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
                .Name = .ResultRange.Cells(3, 1)
            End With

感恩樓上兩位高人的解答,已經順利解決問題了:)

TOP

        靜思自在 : 站在半路,比走到目標更辛苦。
返回列表 上一主題