|
Option Explicit
Sub test()
Dim ar, i&, j&, r&, strFileName$, strPath$
Application.ScreenUpdating = False
strPath = ThisWorkbook.Path & "\"
strFileName = Dir(strPath & "*.xlsb")
Do Until strFileName = ""
With Workbooks.Open(strPath & strFileName)
.Worksheets("Sheet2").Activate
ar = .ActiveSheet.UsedRange.Value
With .Worksheets.Add(after:=.Worksheets(.Worksheets.Count))
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2) + 1)
r = 0
For i = 2 To UBound(ar) Step 3
r = r + 1
ar(i, 14) = ar(i - 1, 13)
For j = 1 To UBound(ar, 2)
br(r, j) = ar(i, j)
Next j
br(r, UBound(br, 2)) = i
Next i
.[A1].Resize(r, UBound(br, 2)) = br
End With
.Close True
End With
strFileName = Dir
Loop
Application.ScreenUpdating = True
Beep
End Sub |
|