String split in excel

Mar 16th, 2016

As there is no split function in excel, you can create a UDF to gain the same functionality as available in languages such as Java, PHP, etc

Create a module and add a function as below:

Function STR_SPLIT(str, sep, n) As String
Dim V() As String
V = Split(str, sep)
STR_SPLIT = V(n - 1)
End Function

 

Let’s say you have “lalitmehta.com” in A1 cell.

On A2 cell you can set it as “=STR_SPLIT(A1, ".", 1)” to get “lalitmehta”

On A3 cell you can set it as “=STR_SPLIT(A1, ".", 2)” to get “com”

Tags:
No comments yet.

Time limit is exhausted. Please reload the CAPTCHA.