0

I am attempting to return and define the split values of a defined string. (in vba) The delimiter of the cell is "@".

Here is an example: "Element1@Element2@Element3@Element4"

I have been successful in doing this when it is only "Element1@Element2" using the following code:

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)

Any idea how to approach this and define values for Element3 and Element4?

Thank you!

1
  • 3
    Have a look at the Split Function Commented Jul 26, 2017 at 19:16

2 Answers 2

2

Try using the Split function on your value:

Dim elements, ele  '' Declared implicitly as Variant type

elements = Split(Linerange.Value, "@")
For Each ele in elements
    Debug.Print ele
Next
Sign up to request clarification or add additional context in comments.

Comments

0
Dim vSplit As Variant
vSplit=Split(Linerange.Value,"@")

You then have an array of vSplit()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.