Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to parse a string

Status
Not open for further replies.

Jeff98

Programmer
Oct 19, 2006
14
US
In excel I have
A1: 1,2,5,7
A2: 2,3 5

I want to parse the strings in A1 and A2 and put the result in B1: 1
C1: 2
D1:
E1:
F1: 5
G1:
H1: 7

B2:
C2: 2
D2: 3
E2:
F2: 5
G2:
H2:

How Can I write a VBA function to do that?
Thanks

JEFF
 
What have you tried so far ?
Tip: have a look at the Split function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Jeff

I'm wondering if you need to parse the data as all you are doing is putting the number into the column denoted by (the same number+1) i.e. 7 is entered in column 8. What's the plan after parsing the data?
 
Thank you for response.
A1: 1,4,8,15

I just want to cout how many "1" , how many "2"s and how many "3" s ....in column A.
If I can split it in excell, I can import the excel file into excess and count it easily.

I guess VBA can do this trick, but i do not know how.

Jeff
 
In which case try this:

Highlight column A
Select Text to Columns in the data menu and then tell it you column is comma delimited (i.e. a comma separates the entries).

Once you have completed that, the entries should be in their own cells.

In a cell under the last entry you can then use the countif function on you split/parsed results. i.e. =Countif(<select the area referred to as Range1>,<enter the integer you are looking to count>).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top