Piotr Żydowicz technolog, Bohamet
Temat: edycja makra, importowanie wiersz po wierszu
Witam, mam makro które importuje mi pliki z danymi csv, teraz gdy wczytuje plik po pliku dane wczytuje mi kolumny obok poprzednich danych a chciałbym aby wczytywało to jedno pod drugim.oto kod :
Sub Elipsa1_Kliknięcie()
Dim R As Long, fstr As String
R = 1
fstr = Dir("*.csv")
With Application.FileDialog(msoFileDialogFilePicker)
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Blad"
End If
'fstr is the file path and name of the file you selected.
fstr = .SelectedItems(1)
ImportCsvFile fstr.ActiveSheet(1, 1)
R = ActiveSheet.UsedRange.Columns.Count + 1
End With
End Sub
Sub ImportCsvFile(fstr As Variant, position As Range)
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & fstr, Destination:=position)
'With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & Filename _
, Destination:=position)
.Name = Replace(fstr, ".csv", "")
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlMacintosh
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = ";"
TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
End Sub