File di testo

7 views
Skip to first unread message

Danilo R

unread,
Jan 30, 2012, 2:21:13 PM1/30/12
to Excel VBA
Ho un file di testo di 50 mega (ebben si mi arriva una cosa del
genere...) con i record di tutti i comuni di Italia
Devo filtrarlo per regione Lombardia e scrivo questo codice:

Sub FiltraComuniMilano()
Open "\MILANO.txt" For Output As #1 'file che mi creo con
solo i comuni di Milano
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("LOMBARDIA.TXT", 1)
Do While Not ts.AtEndOfStream
rs = ts.readline
s = Split(rs, ";")
If s(1) = "MI"" Then Print #1, rs
Loop
ts.Close
Close (1)
End Sub

Ma non esiste un metodo migliore?
Potrei anche creare da codice un db access e fare una query....oppure?
Reply all
Reply to author
Forward
0 new messages