我试图返回并定义已定义字符串的拆分值。 (在vba中)单元格的分隔符是" @"。
以下是一个例子:" Element1 @ Element2 @ Element3 @ Element4"
当它只是" Element1 @ Element2"时,我成功地做到了这一点。使用以下代码:
Sheet1.Range("B1").Value = Linerange.Value
Dim Element1 As String
Dim Element2 As String
Element1 = Left(Linerange.Value, InStr(1, Linerange.Value, "@") - 2)
Element2 = Right(Linerange.Value, Len(Linerange.Value) - InStr(1, Linerange.Value, "@") - 1)
知道如何处理这个并定义Element3和Element4的值吗?
谢谢!
答案 0 :(得分:2)
尝试在您的值上使用Split
function:
Dim elements, ele '' Declared implicitly as Variant type
elements = Split(Linerange.Value, "@")
For Each ele in elements
Debug.Print ele
Next
答案 1 :(得分:0)
Dim vSplit As Variant
vSplit=Split(Linerange.Value,"@")
然后你有一个vSplit()