返回列表 上一主題 發帖

[發問] 請問如何從網路上抓下資料存入excel後"列"不會動

[發問] 請問如何從網路上抓下資料存入excel後"列"不會動

假設以下第一筆存入A80,第二筆存入A100,但第一筆的資料會被推到M80,請問要如何修改。

謝謝!

Sub 新增查詢()
   
    Range("A80").Select
   
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://tw.stock.yahoo.com/q/q?s=1101", Destination:=Selection)
        
        .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 = "3"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
        .Name = .ResultRange.Cells(1, 1)
    End With
   
    Range("A100").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://tw.stock.yahoo.com/q/q?s=1101", Destination:=Selection)
        
        .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

回復 1# cji3cj6xu6
With ActiveSheet.QueryTables.Add->  新增查詢,如Range("A80")有[查詢],會被一直往工作表的右邊移動(不會被覆蓋)

With ActiveSheet.QueryTables(??) -> 第??個外部查詢 ,就不會動到其它的外部查詢.
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

又麻煩您了GBKEE大,
原來是修改此處,謝謝G大。

TOP

        靜思自在 : 道德是提昇自我的明燈,不該是呵斥別人的鞭子。
返回列表 上一主題