macro to download a csv file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to download a csv file(one sheet file) into my excel w/book as a one
of my w/sheet.Is there any macro that do the task.This is a dialy activity I
am doing.Launching IE,browsing the website for related links,finding the
downloaded file,downloading,saving in my documents,extrating from zip
folder,moving the page to w/book,renaming the w/sheet(before renaming
deleting the yesterday's sheet).
The macro should work on w/book open event with time criteria(say everyday
10PM)
 
Hi,

As an example, here is the download of csv related to Yahoo stock
quotes ...

Sub GetYQuotes()
Base01 = "http://finance.yahoo.com/d/quotes.csv?s="
Base02 = "&f=sl1d1t1c1ohgv&e=.csv"
sURL = ""
SymString = ""

LastRow = Cells(65536, 1).End(xlUp).Row

For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i
sURL = Base01 & SymString & Base02
Workbooks.Open sURL
Set rngSource = Cells(1).CurrentRegion
x = rngSource.Rows.Count
y = rngSource.Columns.Count
With ThisWorkbook.Sheets(1)
Set rngDest = Range(.Cells(1, 1), .Cells(x, y))
End With
rngDest.Value = rngSource.Value
ActiveWorkbook.Close SaveChanges:=False
End Sub

HTH
Carim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top