Sub ¿ï¾ÜÀÉ®×()
Dim Arr, WB, fc%, x%, fn$, n%
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
With Sheets("Á`ªí")
If .FilterMode Then .ShowAllData
.Range("a2:j" & .[a65536].End(3).Row) = ""
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "D:\"
.AllowMultiSelect = True
.Show
fc = .SelectedItems.Count
If fc = 0 Then Exit Sub
Tm = Timer
For x = 1 To fc
FPath = .SelectedItems(x)
Set WB = Workbooks.Open(FPath)
With Sheets(1)
If .FilterMode Then .ShowAllData
Arr = .Range("a3:i" & .[a65536].End(3).Row)
fn = Split(ActiveWorkbook.Name, ".")(0)
End With
WB.Close
n = [a65536].End(xlUp).Row + 1
Range("a" & n).Resize(UBound(Arr), UBound(Arr, 2)) = Arr
Range("j" & n & ":j" & [a65536].End(xlUp).Row) = fn
Next
End With
End With
Sub test2()
Dim Arr, WB, fc%, x%, fn$, n%
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
fileorg = ActiveWorkbook.Name
n = 1
With Sheets("Á`ªí")
If .FilterMode Then .ShowAllData
.Range("a1:AA" & .[a65536].End(3).Row).Delete
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "D:\"
.AllowMultiSelect = True
.Show
fc = .SelectedItems.Count
If fc = 0 Then Exit Sub
Tm = Timer
For x = 1 To fc
FPath = .SelectedItems(x)
Set WB = Workbooks.Open(FPath)
With Sheets(1)
If .FilterMode Then .ShowAllData
fn = Split(ActiveWorkbook.Name, ".")(0)
.Range("a1:z" & .[a65536].End(3).Row).Copy Workbooks(fileorg).Sheets("Á`ªí").Range("a" & n)
End With
WB.Close
Range("AA" & n & ":AA" & [a65536].End(xlUp).Row) = fn
n = [a65536].End(xlUp).Row + 1
Next
End With
End With
¦^´_ 44#samwang
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
fileorg = ActiveWorkbook.Name
Set xD = CreateObject("Scripting.Dictionary")
For i1 = 1 To n1
If Not xD.Exists(Ar(i1, 1) & "") Then
xD(Ar(i1, 1) & "") = ""
For i = 1 To n
If Arr(i, 2) = Ar(i1, 1) Then n2 = n2 + 1: Ar1(n2, 1) = Arr(i, 1)
Next
End If
Next
R = 1: Sheets("6¤ë¥÷¼Æ¾Ú").Select
With Sheets("6¤ë¥÷¼Æ¾Ú")
If .FilterMode Then .ShowAllData
.Range("a1:AA" & .[a65536].End(3).Row).Delete
Tm = Timer
For i1 = 1 To n2
Set WB = Workbooks.Open(Ar1(i1, 1))
With Sheets("6¤ë¥÷¼Æ¾Ú")
If .FilterMode Then .ShowAllData
fn = Split(ActiveWorkbook.Name, ".")(0)
.Range("a1:z" & .[a65536].End(3).Row).Copy Workbooks(fileorg).Sheets("6¤ë¥÷¼Æ¾Ú").Range("a" & R)
End With
WB.Close
.Range("U" & R & ":U" & .[a65536].End(xlUp).Row) = fn
R = .[a65536].End(xlUp).Row + 1
Next
End With
MsgBox "¸ê®Æ½Æ»s§¹¦¨" & Timer - Tm & "¬í"
Erase Arr: Erase Ar
Unload Me
¦^´_ 44#samwang
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
fileorg = ActiveWorkbook.Name
Set xD = CreateObject("Scripting.Dictionary")
For i1 = 1 To n1
If Not xD.Exists(Ar(i1, 1) & "") Then
xD(Ar(i1, 1) & "") = ""
For i = 1 To n
If Arr(i, 2) = Ar(i1, 1) Then n2 = n2 + 1: Ar1(n2, 1) = Arr(i, 1)
Next
End If
Next
R = 1: Sheets("6¤ë¥÷¼Æ¾Ú").Select
With Sheets("6¤ë¥÷¼Æ¾Ú")
If .FilterMode Then .ShowAllData
.Range("a1:AA" & .[a65536].End(3).Row).Delete
Tm = Timer
For i1 = 1 To n2
Set WB = Workbooks.Open(Ar1(i1, 1))
With Sheets("6¤ë¥÷¼Æ¾Ú")
If .FilterMode Then .ShowAllData
fn = Split(ActiveWorkbook.Name, ".")(0)
.Range("a1:z" & .[a65536].End(3).Row).Copy Workbooks(fileorg).Sheets("6¤ë¥÷¼Æ¾Ú").Range("a" & R)
End With
WB.Close
.Range("U" & R & ":U" & .[a65536].End(xlUp).Row) = fn
R = .[a65536].End(xlUp).Row + 1
Next
End With
MsgBox "¸ê®Æ½Æ»s§¹¦¨" & Timer - Tm & "¬í"
Erase Arr: Erase Ar
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.AskToUpdateLinks = True
End Sub
Private Sub CommandButton5_Click()
Dim ar2, s%
s = 0: ReDim ar2(s)
With Sheets("Á`ªí").Range("a2:u" & [a65536].End(3).Row)
Sheets(1).AutoFilterMode = False
For i = 0 To ListBox2.ListCount - 1
If ListBox2.Selected(i) = True Then
ReDim Preserve ar2(s)
ar2(s) = CStr(ListBox2.List(i))
s = s + 1
End If
Next
.AutoFilter Field:=7, Criteria1:=ar2, Operator:=xlFilterValues
End With
Set ar2 = Nothing
End Sub§@ªÌ: wang077 ®É¶¡: 2021-7-12 07:57