Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub metrics_get()
  2.  
  3. 'clear old data
  4.    Range("C6:ZZ999").Delete
  5.  
  6.  
  7. 'get list of tickers
  8. For tickers_get = 6 To Cells(6, 1).End(xlDown).Row
  9.  
  10.     tickerstring = tickerstring & "+" & Cells(tickers_get, 1)
  11. Next tickers_get
  12.  
  13. tickerstring = Right(tickerstring, Len(tickerstring) - 1)
  14. tickerstring = "http://download.finance.yahoo.com/d/qoutes.csv?.s=" & tickerstring & "&f=" & Cells(1, 2)
  15.  
  16. 'import data to C6
  17. queryquote:
  18.  
  19.     With ActiveSheet.QueryTables.Add(Connection:="URL;" & tickerstring, Destination:=Range("C6"))
  20.  
  21.         .BackgroundQuery = True
  22.         .Refresh BackgroundQuery:=False
  23.  
  24.     End With
  25.  
  26. 'delimited data
  27. Range("C6").CurrentRegion.TextToColumns Destination:=Range("C6"), DataType:=xlDelimited, comma:=True
  28.  
  29. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement