Discussione: Importare file CSV
Visualizza messaggio singolo
Vecchio 31-10-2017, 15.10.23   #1
Gianca53
Newbie
 
Registrato: 31-10-2017
Messaggi: 25
Gianca53 promette bene
Importare file CSV

Ciao, sono nuovo di questo forum e spero di trovare risposte che non ho trovato altrove.
Il mio problema è di riuscire a scaricare dati da un sito WEB, adottando, se possibile una procedura VBA che mi permetta di avere una tabella CSV che poi provvederò ad elaborare importando alcuni dati in excel.

Ho trovato questa macro :
Quota:
Sub transfercsv()
Dim tk As String, r As Integer
Dim SH1 As Worksheet
'Dim WSW As Worksheet

Set SH1 = ThisWorkbook.Sheets("CSV")
Range("A2") = tk

'FinalRow = SH1.Cells(Rows.Count, 1).End(xlUp).Row

'For r = 2 To FinalRow

SH1.Range("A10:A300").EntireRow.Clear
'http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=KO&reportType=bs&period=1 2&dataType=A&order=asc&columnYear=5&number=3"

sCSVLink = "http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=tk&reportType=bs&period=1 2&dataType=A&order=asc&columnYear=5&number=3"
'
sfile = "options_code_list.csv"
ssheet = "CSV"

Set wnd = ActiveWindow
Application.ScreenUpdating = False
Sheets(ssheet).Cells.ClearContents
Workbooks.Open Filename:=sCSVLink
Windows(sfile).Activate
ActiveSheet.Cells.Copy
wnd.Activate
Sheets("CSV Transfer").Paste
Application.DisplayAlerts = False
Windows(sfile).Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
'Next
End Sub
che, se al posto di tk(ticker), inserisco nella URL di ricerca l'acronimo di un titolo usa , per. es CSCO, funziona bene, ma dato che vorrei associare la ricerca e lo scarico al contenuto della cella "a2" , con tk mi restituisce un foglio CSV bianco. Come a dire che non trova il mio titolo . Ci sto girando attorno da tre giorni senza venirne a capo

Se preferite posso allegare il file excel con la macro già inserita.
Gianca53 non è collegato   Rispondi citando