Vba 存储工作表中的值集合的步骤

Vba 存储工作表中的值集合的步骤,vba,excel,vbscript,Vba,Excel,Vbscript,伪代码: If a=b then result= a . cells(start,1).value end if 若列有多个匹配项,如何将这些匹配值存储在一个变量中?如何将其添加到输入框中,用户可以在提示时从中进行选择 If a=b then result= result & ";" & a.cells(start,1).value end if 你可以考虑连接结果值(上面的例子说明了如何使用一个半群分隔的字符串,该值集合了A= B测试) 不过,您可能需要发布实际代码

伪代码:

If a=b then
result= a . cells(start,1).value
end if
若列有多个匹配项,如何将这些匹配值存储在一个变量中?如何将其添加到输入框中,用户可以在提示时从中进行选择

If a=b then
    result= result & ";" & a.cells(start,1).value
end if

你可以考虑连接结果值(上面的例子说明了如何使用一个半群分隔的字符串,该值集合了A= B测试)

不过,您可能需要发布实际代码,以便能够正确地提供帮助。

为什么不使用数组?(此代码完全未经测试)


这可能有点过头了,这取决于您实际想要实现的目标,但是它会给您提供更多的选择,而不仅仅是将完整结果存储在变量中

对不起,这是什么意思?
Dim arrCount as Long
Dim temp() as Variant

arrCount = 1

If a = b then
    ReDim Preserve temp(1 to arrCount)
    temp(arrCount) = a.cells(start,1).value
    arrCount = arrCount + 1
End If
' Concatenate array together and separate by a semi-colon and a space for the delimiter character
InputBox.Value = Join(temp, "; ")