Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 7152|回复: 1

[已解决]求助:用户定义类型未定义

[复制链接]
发表于 2010-4-8 10:16 | 显示全部楼层 |阅读模式

Sub 查找()
  Dim Dic As New Dictionary为什么会出现用户定义类型未定义的对话框
  Dim Arr, dR_n&, i&, S$, Cnt&
  Dim Rng As Range
    Arr = Sheet3.Range("A3:E" & Sheet1.[a65536].End(xlUp).Row) '把订单明细的数据赋值给ARR
    Range("D3:H" & [d65536].End(xlUp).Row + 1).ClearContents
    For i = 1 To UBound(Arr)
      If Arr(i, 1) >= [A2] And Arr(i, 1) <= [C2] Then
        S = Arr(i, 3)
        If Not Dic.Exists(S) Then
          Dic(S) = Arr(i, 5)
          dR_n = [d65536].End(xlUp).Row + 1
          Cells(dR_n, 4) = Arr(i, 2)
          Cells(dR_n, 5) = Arr(i, 3)
        Else
          Dic(S) = Dic(S) + Arr(i, 5)
        End If
      End If
    Next
    Arr = Sheet7.Range("A3:G" & Sheet2.[a65536].End(xlUp).Row)
    Set Rng = Range("D3:D" & [d65536].End(xlUp).Row)
    For i = 1 To UBound(Arr)
      If Arr(i, 1) >= [A2] And Arr(i, 1) <= [C2] Then
        S = Arr(i, 4)
        If Not Dic.Exists(S) Then
          dR_n = [d65536].End(xlUp).Row + 1
          Cells(dR_n, 4) = Arr(i, 4)
          Cells(dR_n, 5) = Arr(i, 4)
          Cells(dR_n, 7) = Arr(i, 6)
          Set Rng = Range("D3:D" & [d65536].End(xlUp).Row)
        Else
          Cnt = Rng.Find(S).Row
          Cells(Cnt, 6) = Dic(S)
          Cells(Cnt, 7) = Cells(Cnt, 7) + Arr(i, 6)
          Cells(Cnt, 8) = Cells(Cnt, 7) - Dic(S)
        End If
      End If
    Next
End Sub

最佳答案
2010-4-8 10:42

把红色部份改成后期绑定:

Dim d As Object
Set d = CreateObject("Scripting.Dictionary")

或工具-引用-“microsoft scripting runtime”

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2010-4-8 10:42 | 显示全部楼层    本楼为最佳答案   

把红色部份改成后期绑定:

Dim d As Object
Set d = CreateObject("Scripting.Dictionary")

或工具-引用-“microsoft scripting runtime”

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-21 12:21 , Processed in 0.259120 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表