Excel的行的提取?谁告诉我

来源:百度知道 编辑:UC知道 时间:2024/06/04 03:29:15
现在我有很多的EXCEL的文件,每个文件中的A中 在不同的行里有相同的012304,我想把这些所有带有012304的行都提取到一个新的EXCEL表中要怎么办??

是不是每个文件的第一个sheet的A列,用vba,代码如下:
Sub aa()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim myDialog As FileDialog, oFile As Object, strName As String, n As Integer
Dim FSO As Object, myFolder As Object, myFiles As Object
n = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = FSO.GetFolder(ThisWorkbook.Path)
Set myFiles = myFolder.Files
For Each oFile In myFiles
strName = UCase(oFile.Name)
strName = VBA.Right(strName, 3)
If strName = "XLS" And oFile.Name <> ThisWorkbook.Name Then
Cells(n, 1) = oFile.Name
fn = ThisWorkbook.Path & "\" & Cells(n, 1)
Workbooks.Open Filename:=fn
Workbooks(oFile.Name).Activate
With Sheets(1)
m = 1
For n = 1 To .Range