因此,在这里我有一个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