jonesalexr
New Member
- Joined
- Jan 29, 2014
- Messages
- 10
Hello,
I was able to find the below code for a custom function to read a cell and pull back the delimited value to a cell.
I am using the below formula to split the data of B2 into B3,B4,B5 etc
Cell B3=TRIM(ExtractElement($B$2, 1, ";"))
Cell B4=TRIM(ExtractElement($B$2, 2, ";"))
Right now it only works if i use ";" as my delimiter. I would like to use anything but a number or letter as a delimiter. This could include spaces and symbols. The field that is delimited is filled out by various people and will typically use a "," or ";", but i need to include all delimiters.
I was able to find the below code for a custom function to read a cell and pull back the delimited value to a cell.
Code:
Function ExtractElement(str, n, sepChar)
' Returns the nth element from a string,
' using a specified separator character
Dim x As Variant
x = Split(str, sepChar)
If n > 0 And n - 1 <= UBound(x) Then
ExtractElement = x(n - 1)
Else
ExtractElement = ""
End If
End Function
I am using the below formula to split the data of B2 into B3,B4,B5 etc
Cell B3=TRIM(ExtractElement($B$2, 1, ";"))
Cell B4=TRIM(ExtractElement($B$2, 2, ";"))
Right now it only works if i use ";" as my delimiter. I would like to use anything but a number or letter as a delimiter. This could include spaces and symbols. The field that is delimited is filled out by various people and will typically use a "," or ";", but i need to include all delimiters.