|
楼主 |
发表于 2023-2-3 20:35
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 CAONI 于 2023-2-3 20:53 编辑
老师你好,麻烦你把代码发来测试一下,跟我的代码差不多:
Sub 按钮6_Click()
t = Timer
Range("f3:f1048576").ClearContents
Dim i As Long, j As Long, a As Long, b As Long, m As Long, n As Long, k As Long
Dim arr, brr, crr()
Dim d As Object, bb, aa
'打开对比数据arr
Open "d:\bbb.txt" For Input As #1
'将txt文件内容赋值给数组a,a的元素为txt的一行
aa = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf) '将文件号为1的文件的全部字符转换成国际标准化组织 (ISO) 字符标准后传送给a
Close #1
Set d = CreateObject("scripting.dictionary")
For j = 0 To UBound(aa)
If Len(aa(j)) Then
d(Trim(aa(j))) = ""
End If
Next j
'打开总数据crr
Open "d:\aaa.txt" For Input As #1
bb = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf) '将文件号为1的文件的全部字符转换成国际标准化组织 (ISO) 字符标准后传送给a
Close #1
ReDim brr(1 To 500000, 1 To 1)
For i = 0 To UBound(bb)
If Len(bb(i)) Then
If Not d.exists(Trim(bb(i))) Then '如果总数据不在要删除的数据中就提取出来
k = k + 1
brr(k, 1) = bb(i)
End If
End If
Next i
Range("f5").Resize(k, 1) = brr '原总数据余数
Range("f4") = "数据共:" & Application.CountIf(Range("f5:f" & Range("f1048576").End(3).Row), "<>" & "") & "组"
MsgBox "用时 " & Format(Timer - t, "0.00") & "秒"
End Sub |
|