|
| HOMEPAGE | INDICE FORUM | REGOLAMENTO | ::. | NEI PREFERITI | .:: | RSS Forum | RSS News | NEWS web | NEWS software | |
| PUBBLICITA' | | | ARTICOLI | WIN XP | VISTA | WIN 7 | REGISTRI | SOFTWARE | MANUALI | RECENSIONI | LINUX | HUMOR | HARDWARE | DOWNLOAD | | | CERCA nel FORUM » | |
31-10-2017, 15.10.23 | #1 | |
Newbie
Registrato: 31-10-2017
Messaggi: 25
|
Importare file CSV
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:
Se preferite posso allegare il file excel con la macro già inserita. |
|
01-11-2017, 18.35.18 | #2 |
Newbie
Registrato: 12-05-2011
Messaggi: 3
|
Rif: Importare file CSV
Ciao.
Senza entrare nel merito del resto del codice, credo proprio che l'errore stia in Codice:
Range("A2") = tk Codice:
tk = Range("A2") |
01-11-2017, 22.25.05 | #3 |
Newbie
Registrato: 31-10-2017
Messaggi: 25
|
Rif: Importare file CSV
Grazie della risposta, ma ho provato e non funziona, ovvero funziona a metà, vale a dire che mi identifica il tk ( abbreviazione di "ticker") come acronimo di un titolo USA realmente esistente. Ho provato a cambiarlo ma mi carica una pagina bianca .
Allego il file . |
03-11-2017, 10.06.58 | #4 |
Newbie
Registrato: 31-10-2017
Messaggi: 25
|
Rif: Importare file CSV
salvo qualcuno abbia trovato la soluzione , altrimenti lasciate perdere , ho risolto diversamente. Grazie comunque.
|
03-11-2017, 17.30.05 | #5 |
Gold Member
Registrato: 20-05-2004
Loc.: Perugia
Messaggi: 4.188
|
Rif: Importare file CSV
Potresti dire anche come, già che ci sei.
___________________________________
Ogni computer ha la sua storia. Dermatite Seborroica? www.dermatiteseborroica.info |
03-11-2017, 18.55.43 | #6 |
Newbie
Registrato: 12-05-2011
Messaggi: 3
|
Rif: Importare file CSV
C'è anche un altro errore in:
Codice:
sCSVLink = "http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=tk&reportType=bs&period=1 2&dataType=A&order=asc&columnYear=5&number=3" In questo modo tk non viene trattata come una variabile ma come semplice testo. Doveva essere Codice:
sCSVLink = "http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=" & tk & "&reportType=bs&period=1 2&dataType=A&order=asc&columnYear=5&number=3" |
03-11-2017, 22.59.44 | #7 | |
Newbie
Registrato: 31-10-2017
Messaggi: 25
|
Rif: Importare file CSV
Ho fatto in modo da "aggirare l'ostacolo" ovvero in riferimento a una ipotetica cella "D3" ho inserito questa if , e il bello è che funziona pure .
Quota:
|
|
03-11-2017, 23.36.08 | #8 |
Senior Member
WT Expert
Registrato: 19-05-2007
Loc.: Verona
Messaggi: 1.302
|
Rif: Importare file CSV
Non capisco perchè csv, quando puoi avere i dati in un file excel con qualche riga di codice.
Codice:
Sub transfercsv() Dim tk, sCSVLink As String tk = Range("A2") ActiveSheet.Range("A10:A300").EntireRow.Clear sCSVLink = "http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=tk&reportType=bs&period=12&dataType=A&order=asc&columnYear=5&number=3" Workbooks.Open Filename:=sCSVLink End Sub
___________________________________
- Il primo fondamento della sicurezza non e' la tecnologia, ma l'attitudine mentale - |
05-11-2017, 09.20.40 | #9 | ||
Newbie
Registrato: 31-10-2017
Messaggi: 25
|
Rif: Importare file CSV
Grazie Alexandra, ho risolto cosi :
Quota:
Quota:
|
||
05-11-2017, 19.38.54 | #10 |
Senior Member
WT Expert
Registrato: 19-05-2007
Loc.: Verona
Messaggi: 1.302
|
Rif: Importare file CSV
Prova così
Codice:
Sub Trasfercsv() Dim tk, sCSVLink As String tk = Range("A2") ActiveSheet.Range("G1:M300").Clear sCSVLink = "http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=" & tk & "&reportType=bs&period=12&dataType=A&order=asc&col umnYear=5&number=3" Workbooks.Open Filename:=sCSVLink Workbooks("ReportProcess4CSV.html").Sheets("ReportProcess4CSV").Range("A1:F50").Copy _ Destination:=Workbooks("Cartel1.xlsm").Sheets("Foglio1").Range("G1") ActiveWorkbook.Close End Sub Codice:
Sub Trasfercsv() Dim tk, sCSVLink As String tk = Range("A2") ActiveSheet.Range("G1:M300").Clear sCSVLink = "http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=" & tk & "&reportType=bs&period=12&dataType=A&order=asc&col umnYear=5&number=3" Workbooks.Open Filename:=sCSVLink Call prova ActiveWorkbook.Close End Sub Sub prova() Set wk1 = Workbooks("ReportProcess4CSV.html") Set wk2 = Workbooks("Cartel1.xlsm") Set sh1 = wk1.Worksheets("ReportProcess4CSV") Set sh2 = wk2.Worksheets("Foglio1") With sh1 .Range("A1:F50").Copy Destination:=sh2.Range("G1") End With Set sh2 = Nothing Set sh1 = Nothing Set wk1 = Nothing Set wk2 = Nothing End Sub La 1° soluzione la trovo più lineare (e meno codice da scrivere) la 2° è più veloce e professionale.
___________________________________
- Il primo fondamento della sicurezza non e' la tecnologia, ma l'attitudine mentale - |
05-11-2017, 21.43.32 | #11 |
Newbie
Registrato: 31-10-2017
Messaggi: 25
|
Rif: Importare file CSV
Grazie Alexandra, entrambe impeccabili, ora mi aiuti a costruire una macro per ... decidere quale delle due utilizzare ????
Ancora grazie . |
06-11-2017, 21.27.55 | #12 |
Senior Member
WT Expert
Registrato: 19-05-2007
Loc.: Verona
Messaggi: 1.302
|
Rif: Importare file CSV
io userei la 1°, semplice, spartana ma efficace.
___________________________________
- Il primo fondamento della sicurezza non e' la tecnologia, ma l'attitudine mentale - |
Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti) | |
Strumenti discussione | |
|
|
Discussioni simili | ||||
Discussione | Autore discussione | Forum | Risposte | Ultimo messaggio |
Laboratorio di VBA: Programmi e file sorgenti | Alexsandra | Guide | 17 | 16-03-2016 21.33.27 |
Spostare script di "backup" da windows a linux | coguaro | Linux e altri Sistemi Operativi | 8 | 06-08-2013 21.27.56 |
[9x - 3.11] INSTALLARE WINDOWS 3.1 A FIANCO DI WINDOWS 98 | booty island | Windows 9x/Me/NT4/2000 | 1 | 27-11-2012 01.08.51 |
HELP - Dato un file txt con dei nomi ogni rigo, come fare a copiare un certo file, ri | Cavallaudo | Windows 7/Vista/XP/ 2003 | 0 | 18-08-2007 20.16.41 |
Windows file protection:guida | Deuced | Windows 9x/Me/NT4/2000 | 7 | 16-03-2004 09.25.28 |