Hjælp til makro
hej,Jeg vil gerne hente en resultatopgørelse og en balance på samme gang - altså i samme ark.
Når jeg bruger nedenstående macro, får jeg en fejl meddelelse - "compile error next without for"
Nogle som kan løse nedenstående macro?
Sub Financial_data_download()
Dim conString As String
Dim conName As String
Dim txtSymbols(0, 2) As String
txtSymbols(0, 1) = "MSFT"
txtSymbols(0, 2) = "CSCO"
For i = 1 To 2
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = txtSymbols(0, i)
'financial statement
conString = "URL;http://finance.yahoo.com/q/ks?s=" & txtSymbols(0, i) & "+Key+Statistics"
conName = "ks?s=" & txtSymbols(0, i) & "+Key+Statistics"
With ActiveSheet.QueryTables.Add(Connection:=conString, Destination:=Range("$A$1"))
.Name = conName
.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 = """yfncsubtit"",8,10,11,13,15,17,19,21,23"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
conString = "URL;http://finance.yahoo.com/is?s=" & txtSymbols(0, i) & "+Income+Statement&annual"
conName = "ks?s=" & txtSymbols(0, i) & "+Income+Statement&annual"
With ActiveSheet.QueryTables.Add(Connection:=conString, Destination:=Range("$A$50"))
.Name = conName
.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 = """yfncsubtit"",8,10,11,13,15,17,19,21,23"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next i
End Sub