|
Option Explicit
Sub test()
Dim ar, br, i&, r&, strFileName$, strPath$
Application.ScreenUpdating = False
strPath = ThisWorkbook.Path & "\"
strFileName = Dir(strPath & "*.xls")
Do Until strFileName = ""
If strFileName <> ThisWorkbook.Name Then
With Workbooks.Open(strPath & strFileName)
With .Worksheets(2)
r = .Cells(.Rows.Count, "A").End(xlUp).Row
ar = .Range("A1:C" & r).Value
ReDim br(1 To UBound(ar), 0)
For i = 2 To UBound(ar) Step 3
br(i, 0) = ar(i, 1) - ar(i - 1, 1)
Next i
[D1].Resize(UBound(br)) = br
End With
.Close True
End With
End If
strFileName = Dir
Loop
Application.ScreenUpdating = True
Beep
End Sub
|
|