Sunteți pe pagina 1din 4

Sub Main()

Dim StartTime, EndTime As Double


StartTime = Timer
Application.ScreenUpdating = False
ThisWorkbook.Worksheets(1).Cells.ClearContents

Dim FolderName As String: FolderName = ThisWorkbook.Path & "\"


Dim FileList() As String
Dim file_name As Variant
Dim interval As String
Dim i As Integer: i = 2
Dim result_arr() As Double

interval = InputBox("input interval")


If Len(interval) = 0 Then
MsgBox ("Please input again")
Exit Sub
Else
interval = CInt(interval)
End If

FileList = GetFileName(FolderName)

For Each file_name In FileList


Workbooks.Open FileName:=FolderName & file_name
result_arr = ResizeData(interval, 2)
ActiveWorkbook.Close False
ThisWorkbook.Activate
Cells(1, i).Value = FilterName(file_name)
ActiveSheet.Range(Cells(LBound(result_arr) + 2, i), _
Cells(UBound(result_arr) + 2, i)).Value
_
=
Application.WorksheetFunction.Transpose(result_arr)
i=i+1
Erase result_arr
Next file_name
result_arr = GetWavelength(FolderName & FileList(0), interval)
ThisWorkbook.Activate
ActiveSheet.Range(Cells(LBound(result_arr) + 2, 1), _
Cells(UBound(result_arr) + 2, 1)).Value _
=
Application.WorksheetFunction.Transpose(result_arr)
Application.ScreenUpdating = True
EndTime = Timer
Debug.Print ("Required Time: " & EndTime - StartTime & " seconds")
End Sub

Sub Main()
Dim StartTime, EndTime As Double
StartTime = Timer
Application.ScreenUpdating = False
ThisWorkbook.Worksheets(1).Cells.ClearContents

Dim FolderName As String: FolderName = ThisWorkbook.Path & "\"


Dim FileList() As String
Dim file_name As Variant
Dim interval As String
Dim i As Integer: i = 2
Dim result_arr() As Double

interval = InputBox("input interval")


If Len(interval) = 0 Then
MsgBox ("Please input again")
Exit Sub
Else
interval = CInt(interval)
End If

FileList = GetFileName(FolderName)

For Each file_name In FileList


Workbooks.Open FileName:=FolderName & file_name
result_arr = ResizeData(interval, 2)
ActiveWorkbook.Close False
ThisWorkbook.Activate
Cells(1, i).Value = FilterName(file_name)
ActiveSheet.Range(Cells(LBound(result_arr) + 2, i), _
Cells(UBound(result_arr) + 2, i)).Value
_
=
Application.WorksheetFunction.Transpose(result_arr)
i=i+1
Erase result_arr
Next file_name
result_arr = GetWavelength(FolderName & FileList(0), interval)
ThisWorkbook.Activate
ActiveSheet.Range(Cells(LBound(result_arr) + 2, 1), _
Cells(UBound(result_arr) + 2, 1)).Value _
=
Application.WorksheetFunction.Transpose(result_arr)
Application.ScreenUpdating = True
EndTime = Timer
Debug.Print ("Required Time: " & EndTime - StartTime & " seconds")
End Sub

Sub Main()
Dim StartTime, EndTime As Double
StartTime = Timer
Application.ScreenUpdating = False
ThisWorkbook.Worksheets(1).Cells.ClearContents

Dim FolderName As String: FolderName = ThisWorkbook.Path & "\"


Dim FileList() As String
Dim file_name As Variant
Dim interval As String
Dim i As Integer: i = 2
Dim result_arr() As Double

interval = InputBox("input interval")


If Len(interval) = 0 Then
MsgBox ("Please input again")
Exit Sub
Else
interval = CInt(interval)
End If

FileList = GetFileName(FolderName)

For Each file_name In FileList


Workbooks.Open FileName:=FolderName & file_name
result_arr = ResizeData(interval, 2)
ActiveWorkbook.Close False
ThisWorkbook.Activate
Cells(1, i).Value = FilterName(file_name)
ActiveSheet.Range(Cells(LBound(result_arr) + 2, i), _
Cells(UBound(result_arr) + 2, i)).Value
_
=
Application.WorksheetFunction.Transpose(result_arr)
i=i+1
Erase result_arr
Next file_name
result_arr = GetWavelength(FolderName & FileList(0), interval)
ThisWorkbook.Activate
ActiveSheet.Range(Cells(LBound(result_arr) + 2, 1), _
Cells(UBound(result_arr) + 2, 1)).Value _
=
Application.WorksheetFunction.Transpose(result_arr)
Application.ScreenUpdating = True
EndTime = Timer
Debug.Print ("Required Time: " & EndTime - StartTime & " seconds")
End Sub

S-ar putea să vă placă și