多个链接的宏
Macro for Multiple links
如何loop/run 代码根据 .txt 文件中的列表,直到列表结束?
如何loop/run 代码根据 .txt 文件中的列表,直到列表结束?
Sub FundData()
Dim TikerName As String
TikerName = 'check & execute the names in list one after one in .txt file until it ends up
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://example.com/index.php?name=" & TikerName, Destination:=Range( _
"$A"))
'.CommandType = 0
.Name = "name=" & TikerName
.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 = """company"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveSheet.Name = TikerName
Sheets.Add After:=ActiveSheet
ThisWorkbook.Save
End Sub
创建类似这样的结构:
Sub FundData()
Dim TikerName As String
Open "C:\somepath\sometextfile.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, TikerName
' your main code goes here
Loop
Close #1
ThisWorkbook.Save
End Sub
如何loop/run 代码根据 .txt 文件中的列表,直到列表结束?
如何loop/run 代码根据 .txt 文件中的列表,直到列表结束?
Sub FundData()
Dim TikerName As String
TikerName = 'check & execute the names in list one after one in .txt file until it ends up
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://example.com/index.php?name=" & TikerName, Destination:=Range( _
"$A"))
'.CommandType = 0
.Name = "name=" & TikerName
.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 = """company"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveSheet.Name = TikerName
Sheets.Add After:=ActiveSheet
ThisWorkbook.Save
End Sub
创建类似这样的结构:
Sub FundData()
Dim TikerName As String
Open "C:\somepath\sometextfile.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, TikerName
' your main code goes here
Loop
Close #1
ThisWorkbook.Save
End Sub