how do i extract multiple data from a cell(string) whose length v.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to extract all numbers into different columns (delimiter is ,). e.g.
1,325,16420,5,6,120,4643,2,8,-71,-68,-6 the length of numbers within
could vary.
 
Put you comma delimited string in cell A1. code will put numbers starting in
row 2 cell A2.

Sub splitstring()

MyString = Range("A1").Value
MyOff = 0
Do While InStr(MyString, ",") > 0
MyNum = Val(Left(MyString, InStr(MyString, ",") - 1))
MyString = Mid(MyString, InStr(MyString, ",") + 1)
Range("A2").Offset(0, MyOff).Value = MyNum
MyOff = MyOff + 1
Loop
MyNum = Val(MyString)
Range("A2").Offset(0, MyOff).Value = MyNum

End Sub
 
Data/Text to Columns/separated by comma

Regards,
Stefi

„Gits†ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top