Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含由竖线分隔的数据的单元格,像这样(A|B|C),我想读取它们并分配给一个变量,以便:
(A|B|C)
A
B
我还想计算这些变量的数量。
利用Split
Split
如果您的值在,A1那么以下代码会自动将第一个变量放入 中vArr(0),将第二个变量放入vArr(1). 您可以遍历变体数组 vArr 以访问各个值
A1
vArr(0)
vArr(1)
vArr = Split(Range("A1"), "|") MsgBox "Number of items = " & UBound(vArr) + 1