Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays VBA::整合阵列_Arrays_Vba_Consolidation - Fatal编程技术网

Arrays VBA::整合阵列

Arrays VBA::整合阵列,arrays,vba,consolidation,Arrays,Vba,Consolidation,我正在创建一个搜索功能,允许用户在数据库prop1、2和3中同时搜索最多3个不同的属性。我在VBA中创建了此子项,将搜索到的属性的结果放入数组中。但是,现在我有了最多3个阵列,我需要合并这些阵列,以便在结果中只显示阵列中重复的数据。对于如何1只查看用户正在搜索的属性的数组,2只获取重复到最终数组中的数据,以便在结果范围内显示,是否有任何建议?非常感谢您的帮助!谢谢 假设您的条目直接来自数据库,因此对于一个属性是唯一的,我可以考虑以下步骤来获得一个简单的解决方案: 将数组合并到一起prop1、pr

我正在创建一个搜索功能,允许用户在数据库prop1、2和3中同时搜索最多3个不同的属性。我在VBA中创建了此子项,将搜索到的属性的结果放入数组中。但是,现在我有了最多3个阵列,我需要合并这些阵列,以便在结果中只显示阵列中重复的数据。对于如何1只查看用户正在搜索的属性的数组,2只获取重复到最终数组中的数据,以便在结果范围内显示,是否有任何建议?非常感谢您的帮助!谢谢

假设您的条目直接来自数据库,因此对于一个属性是唯一的,我可以考虑以下步骤来获得一个简单的解决方案:

将数组合并到一起prop1、prop2、prop3>temp 计数此示例代码tempCount中每个元素的出现次数 根据有关引用的知识,在此处创建名为result的最终数组

为了检查一些示例,我将其添加到代码中。它只是将数组temp、result和tempCount打印到A、B和C列

'some sample arrays
prop1 = Array("a", "b", "c", "d", "e")
prop2 = Array("b", "c", "f")
prop3 = Array("b", "c", "d", "g")

'some sample Output

'temp
Cells(1, 1).Value = "temp:"
For i = 0 To UBound(temp)
    Cells(i + 2, 1).Value = temp(i)
Next i

'result
Cells(1, 2).Value = "result:"
For i = 0 To UBound(result)
    Cells(i + 2, 2).Value = result(i)
Next i

'count:
Cells(1, 3).Value = "count:"
For i = 0 To UBound(tempCount)
    Cells(i + 2, 3).Value = tempCount(i)
Next i

注意:tempCount只保存元素被监视时的累计出现次数。

能否向我们展示部分代码和您尝试的内容?也许您可以在代码结束之前合并数组
'some sample arrays
prop1 = Array("a", "b", "c", "d", "e")
prop2 = Array("b", "c", "f")
prop3 = Array("b", "c", "d", "g")

'some sample Output

'temp
Cells(1, 1).Value = "temp:"
For i = 0 To UBound(temp)
    Cells(i + 2, 1).Value = temp(i)
Next i

'result
Cells(1, 2).Value = "result:"
For i = 0 To UBound(result)
    Cells(i + 2, 2).Value = result(i)
Next i

'count:
Cells(1, 3).Value = "count:"
For i = 0 To UBound(tempCount)
    Cells(i + 2, 3).Value = tempCount(i)
Next i