|
Sub サンプルマクロ()
Dim myDir As String
Dim myFileName As String
Dim wbcsv As Workbook, wscsv As Worksheet
Dim wb As Workbook, ws As Worksheet
Dim r As Long
myDir = "C:\Data\"
myFileName = Dir(myDir & "*.csv")
Set wb = Workbooks.Add
Set ws = wb.Worksheets(1)
ws.Name = "data"
r = 1
Do While myFileName <> ""
If myFileName <> ThisWorkbook.Name Then
Set wbcsv = Workbooks.Open(myDir & myFileName)
Set wscsv = wbcsv.Worksheets(1)
wscsv.UsedRange.Copy ws.Cells(r, 1)
r = ws.Range("A65536").End(xlUp).Offset(1).Row
wbcsv.Close False
myFileName = Dir()
End If
Loop
wb.Activate
MsgBox "完了"
End Sub
|
|