0
하위 결합()VBA 루핑 - 열에서 값을 사용하여
Dim stockcode As String
Dim marketcode As String
stockcode = Sheets("NYSE screener").Range("B1").Value
marketcode = Sheets("Stock input").Range("B2").Value
Sheets.Add.Name = stockcode & "BS"
With Worksheets(stockcode & "BS").QueryTables.Add(Connection:= _
"URL;http://markets.ft.com/research/Markets/Tearsheets/Financials?s=" & stockcode & ":" & marketcode & "&subview=BalanceSheet", Destination:=Range(_
"$A$1"))
'.Name = "67083361_zpid"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Worksheets(stockcode & "BS").Range("A115:F153").Select
Selection.Copy
Worksheets(stockcode & "BS").Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Worksheets(stockcode & "BS").Rows("40:170").Clear
Sheets.Add.Name = stockcode & "CF"
With Worksheets(stockcode & "CF").QueryTables.Add(Connection:= _
"URL;http://markets.ft.com/research/Markets/Tearsheets/Financials?s=" & stockcode & ":" & marketcode & "&subview=CashFlow", Destination:=Range(_
"$A$1"))
'.Name = "67083361_zpid"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Worksheets(stockcode & "CF").Range("A115:F142").Select
Selection.Copy
Worksheets(stockcode & "CF").Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Worksheets(stockcode & "CF").Rows("29:159").Clear
Sheets.Add.Name = stockcode & "IS"
With Worksheets(stockcode & "IS").QueryTables.Add(Connection:= _
"URL;http://markets.ft.com/research/Markets/Tearsheets/Financials?s=" & stockcode & ":" & marketcode & "&subview=IncomeStatement", Destination:=Range(_
"$A$1"))
'.Name = "67083361_zpid"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Worksheets(stockcode & "IS").Range("A115:F161").Select
Selection.Copy
Worksheets(stockcode & "IS").Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Worksheets(stockcode & "IS").Rows("48:178").Clear
최종 하위
'나는 뉴욕 증권 거래소의 스크리너라는 또 다른 워크 시트의 주식 코드의 열을 가지고있다. 값을 사용하고 전체 코드를 실행하여 세 개의 개별 워크 시트를 얻고 싶습니다. 어떻게 루프를 만들 수 있습니까? 값은 뉴욕 증권 거래소의 스크리너의 열 B에
안녕하세요, Isaac, 우선 재고 목록을 배열로 정의한 다음 재고 목록의 각 항목에 대해 전체 매크로를 수행하도록 정의해야합니다. 배열을 검색 할 위치를 어떻게 정의합니까? – user3758532