请各位老师帮忙看看~~这段封装的com加载项代码有什么问题吗~为什么可以提示完成但是没有相应的文件生成~把代码复制到Excel宏里又可以正常完成~
Public Sub 拆分()Dim d As Object
Dim arr, ip, r, i, aa
Dim wb As Workbook
xlApp.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
With xlApp.ActiveSheet
ip = xlApp.InputBox("请输入要拆分的参照值所在的列数(输入值应为数字)")
r = xlApp.Cells(xlApp.Rows.Count, 2).End(xlUp).Row
arr = xlApp.Range("a1:t" & r)
For i = 2 To UBound(arr)
If Not d.Exists(arr(i, ip)) Then
Set d(arr(i, ip)) = xlApp.Union(xlApp.Cells(1, 1).Resize(1, 20), xlApp.Cells(i, 1).Resize(1, 20))
Else
Set d(arr(i, ip)) = xlApp.Union(d(arr(i, ip)), xlApp.Cells(i, 1).Resize(1, 20))
End If
Next
End With
For Each aa In d.keys
Set wb = xlApp.Workbooks.Add
With wb
With .Worksheets(1)
d(aa).Copy .Range("a1")
.Name = aa
End With
.SaveAs xlApp.ThisWorkbook.Path & "\" & aa
.Close False
End With
Next
xlApp.ScreenUpdating = True
MsgBox "数据拆分完毕!"
End Sub