String split in excel

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”

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.