Friday, 25 October 2013

Excel Macro to split the cell value or string

Sub breakString()

'Excel macro to split the string with given delemiter or seperator

string1 = "sachin , suresh, Yuvraj, dhoni, Ishant, shikhar"

arrString = Split(string1, ",", 2)
'Split function will break the given string using seperator
'in above code we have split string1 using ","
'Last parameter indicates how many parts should be made of the given string
'Last parameter is optional and if ommitted string will be broken into maximum number of parts


For i = 0 To UBound(arrString)
    MsgBox arrString(i)
Next

'Output - "sachin" and "suresh, Yuvraj, dhoni, Ishant, shikhar"
End Sub


What do you think on above excel macro topic? Please provide your input, comments, questions on excel macro. I will try to reply as soon as possible. I value your opinion on Excel Macros.

No comments:

Post a Comment

Popular Posts

Search This Blog