|
書き込みありがとうございます.
これは本を読みながら自分で作ったのです↓
Sub CSV()
Dim fs As Object, fd As FileDialog
Dim fStr As String, fName As Variant, i As Integer
Set fs = CreateObject("Scripting.FileSystemObject")
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = True
.Title = "データ選択(ファイル参照)"
.Filters.Add "テキストファイル", "*.csv"
If .Show = 0 Then Exit Sub
End With
If fd.SelectedItems.Count < 2 Then
MsgBox "データを複数選んでください"
Exit Sub
End If
With fs.OpenTextFile(fd.SelectedItems(1), 1)
fStr = .ReadAll
.Close
End With
For i = 2 To fd.SelectedItems.Count
With fs.OpenTextFile(fd.SelectedItems(i), 1)
fStr = fStr & vbCrLf & .ReadAll
.Close
End With
Next i
fName = Application.GetSaveAsFilename( _
InitialFileName:="ファイル.xls", _
FileFilter:=",*.xls")
If fName = False Then Exit Sub
With fs.CreateTextFile(fName)
.Write fStr
.Close
ActiveWorkbook.SaveAs FileFormat:=xlNormal
End With
End Sub
これは
記録したマクロです
↓↓↓
Application.Left = 440.5
Application.Top = 8.5
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\www\home\簡易システム\UsabilityProject\jiro\1\眼球運動ログデータ\加工データ\1.csv", _
Destination:=Range("A1"))
.Name = "1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 932
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _
, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
理想はシート1とシート2連結したの入れて統計するつもりです
|
|