因此,在這裏我有一個vba代碼,它爲不同的公司填充財務報表,當我第一次運行宏時,它將信息從B列粘貼到G,但是當我重新運行它時,它將粘貼到列H到M中舊數據的右側,而不是刪除舊數據。我希望它刪除舊數據,以便將新的信息粘貼到列B到G中,每次運行宏時都會覆蓋舊數據。財務報表粘貼在舊的
以下是我的代碼
非常感謝!
Sub finstate()
sTicker = Range("A1").Value
If sTicker = "" Then
MsgBox "No value to look up"
Exit Sub
End If
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.advfn.com/stock-market/NASDAQ/" & sTicker & "/financials?btn=annual_reports&mode=company_data" _
, Destination:=Range("B2"))
.Name = "financials?btn=annual_reports&mode=company_data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "6"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
這個工作。非常感謝! – Sebastian
你可以標記爲完成,thx! – Ionut