Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good Morning,
I have viewed many discussions relating to web queries from Yahoo stock quotes but I have yet to find information on the following. Is there a truncated code to perform the following function: Sub Macro1() With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://table.finance.yahoo.com/d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=nt.to" _ , Destination:=Sheets("Sheet1").Range("A3")) .Name = "d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=nt.t o" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlAllTables .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .Refresh BackgroundQuery:=False End With With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://table.finance.yahoo.com/d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=zl.to" _ , Destination:=Sheets("Sheet2").Range("A3")) .Name = "d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=zl.t o" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlAllTables .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .Refresh BackgroundQuery:=False End With End Sub I would like to perform this task to a list of stocks, however, I am sure my coding is redundant. Is there a way to simplify the above to state the connections such as: 1) With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://table.finance.yahoo.com/d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=nt.to" _ , Destination:=Sheets("Sheet1").Range("A3")) .Name = "d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=nt.t o" 2) With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://table.finance.yahoo.com/d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=zl.to" _ , Destination:=Sheets("Sheet2").Range("A3")) .Name = "d?a=7&b=27&c=2004&d=10&e=29&f=2004&g=d&s=zl.t o" And then the conditions to apply to all my queries: .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlAllTables .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .Refresh BackgroundQuery:=False This would really help condense the coding issues. Any help would be greatly appreciated. Sincerely, Charles Kent |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
link truncated | Links and Linking in Excel | |||
Hyperlinks are truncated | Excel Discussion (Misc queries) | |||
GIF File Gets Truncated | Charts and Charting in Excel | |||
Printing truncated | Excel Discussion (Misc queries) | |||
Picture will be truncated | Excel Discussion (Misc queries) |