Reputation: 305
Supposedly I have an excel column which looks like this:
How do I achieve this using excel formula:
Right now, I am able to retrieve these using:
=LEFT(D2,SEARCH(";",D2,1)-1)
(First)
=MID(D2, SEARCH(";",D2) + 1, SEARCH(";",D2,SEARCH(";",D2)+1)-SEARCH(";",D2)-1)
(Second)
=RIGHT(D2,SEARCH(";",D2,1)-1)
(Third)
I'd realised that the text was cut off for the RIGHT
formula. How can I separate the text using CHAR(10)
when each semicolon is found?
Upvotes: 1
Views: 3311
Reputation: 811
Got the same problem and used Python code to replace semicolons with commas.
input_file = 'your_csv_file.csv'
output_file = 'converted_csv_file.csv'
with open(input_file, 'r', encoding='utf-8') as infile, open(output_file, 'w', encoding='utf-8') as outfile:
for line in infile:
outfile.write(line.replace(';', ','))
Open the output file using Excel. Now it will show in separate columns nicely.
Upvotes: 1
Reputation: 19782
You need to replace the semi-colon and space with a semi-colon and new line character.
Use =SUBSTITUTE(A1,"; ", ";" & CHAR(10))
and ensure the cell has text wrapping on.
Upvotes: 3
Reputation: 2016
Or just use
split()
to split your cell value by ";" and
trim()
to cut off additional spaces.
Upvotes: 0
Reputation: 244
Click on Data from the main menu then click on Text to Columns. Choose the option delimited and tick the semicolon option. Follow the wizard and you'll get your data formatted as requested.
Upvotes: 0