By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,557 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,557 IT Pros & Developers. It's quick & easy.

splitting the message seperated by , or space

P: 1
hi,

In Excel by using macro split one message into different columns by using vb script.
for ex: in A1 message <murthy,ram,ravi> this is the message.it will split into
B1 murthy,C1 Ram, D1 Ravi.like this the message split.
can any one give me answer the question
Dec 28 '07 #1
Share this Question
Share on Google+
2 Replies


daniel aristidou
100+
P: 491
hi,

In Excel by using macro split one message into different columns by using vb script.
for ex: in A1 message <murthy,ram,ravi> this is the message.it will split into
B1 murthy,C1 Ram, D1 Ravi.like this the message split.
can any one give me answer the question
You could try using the mid and trim functions combined with the len function.
Alternatively you could loop through the string. analyzing each character seperately.
Dec 28 '07 #2

daniel aristidou
100+
P: 491
here is what i came up with very quickly it does need fixing.
Basicly getmsg1 will return ur first message
Getmsg2 will return the second
Getmsg3 will return the third
Expand|Select|Wrap|Line Numbers
  1. Dim message As String
  2. Dim getpositionofcomma As Integer
  3. message = "1,2,3,4"
  4.  
  5. getpositionofcomma1 = InStr(1, message, ",")
  6. getmsg1 = Mid(message, 1, getpositionofcomma1)
  7. message2 = Mid(message, getpositionofcomma1 + 1, Len(message))
  8. getpositionofcomma2 = InStr(1, message2, ",")
  9. getmsg2 = Mid(message2, 1, getpositionofcomma2)
  10. message3 = Mid(message2, getpositionofcomma2 + 1, Len(message))
  11. getpositionofcomma3 = InStr(1, message3, ",")
  12. getmsg3 = Mid(message3, 1, getpositionofcomma3)
Note this is simply to put you on the right track
Regards Daniel
Dec 28 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.