|
こんにちは
お試しを。
(ファイル名のあるシート名をSheet1にしていますのでそちらの環境に合わせてください。)
Sub Macro1()
Dim LastCell As Range, c As Range, Wb As Workbook, strFileName As String
Dim i As Long, Co As Long
With ThisWorkbook.Worksheets("Sheet1")
Set LastCell = .Range("A1", .Range("A65536").End(xlUp)) _
.SpecialCells(xlCellTypeConstants)
strFileName = "C:\WINDOWS\フォルダ1\"
Application.ScreenUpdating = False
Co = 1
For Each c In LastCell
If Len(Dir(strFileName & c.Value)) = 1 Then
Set Wb = Workbooks.Open(strFileName & c.Value)
For i = 1 To 10
.Cells(Co, 2).Value = _
Wb.ActiveSheet.Cells(i, 1).Value + Wb.ActiveSheet.Cells(i, 2).Value
Co = Co + 1
Next i
Wb.Close SaveChanges:=False
Set Wb = Nothing
End If
Next c
Application.ScreenUpdating = True
End With
Set LastCell = Nothing
End Sub
|
|