‘壹’ excel如何统计一个文件夹多个excel里的内容
1
新建一个空白的Excel文件,点击数据工具栏,依次选择“新建查询”-“从文件”-“从文件夹”。
‘贰’ VBA查找文件夹下所有excel文件中的相关数据
事实上可以实现的,我给你一个思路,一是遍历所有文件!这是可以办到的,给你一段代码?这个代码我用来遍历文件名称的,根据指定目标找出所有文件!当然还有一个控件我发不上来!
Private Sub filesexcel_Click()
Dim fd As Object
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
'开启Excel内建的资料夹浏览方块
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
If fd.Show = -1 Then
LookIn = fd.SelectedItems(1)
Else
MsgBox "您未选择浏览目标文件夹!", 48, "系统提示": Exit Sub
End If
Sheet1.Range("A4:IV65536").Clear
Application.ScreenUpdating = False
Dim i As Long
Dim strName As String
Dim strNewNme As String
Dim CaZao As New FilesSearch.glFilesSearch
Application.DisplayAlerts = False
With CaZao
.LookIn = fd.SelectedItems(1)
.FileType =
'.Filename = "*.xls*" '这里可以打开任何类型的工作簿文件
.SearchSubFolders = True
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Sheet1.Range("A" & Sheet1.[A65536].End(xlUp).Row + 1) = i
Sheet1.Range("B" & Sheet1.[A65536].End(xlUp).Row).Hyperlinks.Add Anchor:=Sheet1.Range("B" & Sheet1.[A65536].End(xlUp).Row), Address:=.FoundFiles(i), TextToDisplay:=.FoundFiles(i)
Sheet1.Range("c" & Sheet1.[A65536].End(xlUp).Row) = GetFileType(.FoundFiles(i))
Sheet1.Range("D" & Sheet1.[A65536].End(xlUp).Row) = FileLen(.FoundFiles(i))
Sheet1.Range("E" & Sheet1.[A65536].End(xlUp).Row) = FileDateTime(.FoundFiles(i))
Next i
Else
MsgBox "您选择的目录没有Excel文件!", vbQuestion, Title:="系统信息"
End If
End With
Set CaZao = Nothing
Range("A:A,D:D").Select
Selection.HorizontalAlignment = xlCenter
Sheet1.Range("A4").Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
然后,再增加用循环统计这些表名称旨定单元格的值就行了!而你说的那种,把所有表的某一行找出来,思路是有问题的!而是这些表以行数据的形式存在,然后根据输入的数据在后面显示行的值!有机会我帮做做哦!