View Single Post
Old 25-01-2010, 15:36   #52
fracarro
Senior Member
 
L'Avatar di fracarro
 
Iscritto dal: Jul 2002
Messaggi: 865
Sono riuscito a risolvere il problema creando questa macro:

Codice:
Sub copia_mia()
'
' copia_mia Macro
'
' Scelta rapida da tastiera: CTRL+k
'
ChDrive "D"
ChDir "D:\pippo\"
FileNome = Application.GetOpenFilename("Text Files (*.txt), *.txt")
    Application.CutCopyMode = False
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & FileNome, Destination:= _
        Range("$A$3"))
        .Name = "new2_1"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 850
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = True
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = True
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
        .TextFileDecimalSeparator = "."
        .TextFileThousandsSeparator = ","
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
End Sub
La macro apre la finestra "sfoglia" (a partire dalla cartella pippo sulla partizione D) per permettere la selezione del file di input e poi lo importa usando spazi e tab come delimitatori, il punto come separatore decimale e la virgola come separatore delle migliaia.
Spero che possa essere utile anche a qualcun altro.
__________________
Notebook: MBP 15 i7 Retina, (Mid 2014)

Ultima modifica di fracarro : 25-01-2010 alle 15:38.
fracarro è offline   Rispondi citando il messaggio o parte di esso