我有一个宏从两张纸中提取数据并将它们连接成一行。
当我运行基于帐号合并数据的代码时,我遇到类型不匹配错误。错误出现在下面的* d行。
这是我的测试数据。
Acc Num Name Date of Birth Country Revenue Start Date
25769886 Andreas Ottmar 07/01/1962 DE 106330 01/04/2017
代码:
With Worksheets("customerrevenue")
For x = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
*** key = .Cells(x, 2).Value & "|" & .Cells(x, 3).Value & "|" & .Cells(x, 4).Value
If list.Count = 0 Then ReDim results(0 To 5, 0 To 0)
If list.Contains(key) Then
IndexOf = list.LastIndexOf(key)
results(0, IndexOf) = results(0, IndexOf) & " & " & .Cells(x,
1).Value
results(4, IndexOf) = results(4, IndexOf) + .Cells(x, 5).Value
results(5, IndexOf) = results(5, IndexOf) & " & " & .Cells(x,
6).Value
申报人:
Dim key As Variant, values As Variant, results As Variant
Dim list As Object
Dim x As Long, IndexOf As Long
Set list = CreateObject("System.Collections.ArrayList")