|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
论坛vba大佬,求助以下代码作用:将两组数不同进行比较,把不同的数重新排列输出,但是代码有时能运行有时报错!!!折磨啊~~
求助帮忙看看:
Private Sub CommandButton58_Click()
Dim arr(), brr(), al, all, bl
Dim cfile As Workbook, cpath
Dim i, d, d1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
If TextBox1.Value = "" Then
MsgBox "无数据", vbExclamation, "错误!"
Exit Sub
End If
cpath = TextBox1.Value
Set cfile = GetObject(cpath)
cfile.Sheets("架构表").Activate
Sheet64.Activate
Set d = CreateObject("Scripting.Dictionary")
Set d1 = CreateObject("Scripting.Dictionary")
al = cfile.Sheets("架构表").range("A2" & 4 ^ 8).End(xlUp).Row
all = al - 1
arr() = cfile.Sheets("架构表").range("A2:A" & all).Value
bl = Sheets("架构表").range("a" & 4 ^ 8).End(xlUp).Row
brr = Sheets("架构表").range("A3:b" & bl).Value
For i = 1 To UBound(brr)
d(brr(i, 1)) = brr(i, 1)
Next
For i = 1 To UBound(arr)
If Not d.Exists(arr(i, 1)) Then
d1(arr(i, 1)) = arr(i, 1)
End If
Next
Sheet59.[a1].Resize(d1.Count, 1) = Application.Transpose(d1.keys)’就是这步时而能运行时而报错:类型不匹配T.T
cfile.Close False
Set cfile = Nothing
MsgBox "OK", vbExclamation, "!"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
End Sub
|
|