我有一个包含155个Excel文件的文件夹。我必须将所有155个Excel文件中的F行复制到一个常用工作表中。使用宏
可以做到这一点由于 拉维〜
答案 0 :(得分:0)
您是说F列吗?怎么样?
Sub LoopThroughDirectory()
Dim MyFile As String
Dim Filepath As String
Dim count as Integer
Filepath = "D:\DATA\"
MyFile = Dir(Filepath)
count = 1
Application.ScreenUpdating = False
While MyFile <> ""
If MyFile = "master.xlsm" Then Exit Sub
Workbooks.Open (Filepath & MyFile)
Workbooks(MyFile).sheets("Sheet1").Range("F1:F100").Copy thisworkbook.sheets("Sheet1").Cells(3, count)
Workbooks(MyFile).Close
count = count + 1
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub