|
Sub 按钮1_Click()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
a = 2
Set sh = ActiveSheet
sh.UsedRange.Offset(1).ClearContents
brr = Array("姓名", "专业", "年龄")
Dim crr(2 To 4) As Integer
Set fso = CreateObject("scripting.filesystemobject")
For Each f In fso.getfolder(ThisWorkbook.Path).Files
If f.Name <> ThisWorkbook.Name Then
With Workbooks.Open(f)
For j = 0 To 2
crr(j + 2) = .Sheets(1).Rows(1).Find(brr(j), lookat:=xlWhole).Column
Next j
arr = .Sheets(1).UsedRange
For j = 2 To UBound(arr)
If Len(arr(j, 2)) > 0 Then
For i = 2 To 4
sh.Cells(a, i) = arr(j, crr(i))
Next i
sh.Cells(a, 1) = Split(f.Name, ".xl")(0)
a = a + 1
End If
Next j
.Close False
End With
End If
Next f
Application.DisplayAlerts = tr
Application.ScreenUpdating = True
End Sub
|
|