简体   繁体   English

在Excel中将单元格拆分为由字符串和分号分隔的列

[英]Split cell into columns delimited by string and semicolon in Excel

I have got a list of cells in this format: 我有这种格式的单元格列表:

A1 >> Industry Type: Home & Garden,Import/Export/Wholesale, Location: Auckland,Hawkes Bay,Wellington, PriceRange: $250,000 to $400,000, Order By: Latest Listings

A2 >> Industry Type: Retail General,Technology / Computer / IT,Retail Food,Cafes, Location: Auckland,Wellington, PriceRange: Up to $100,000, Order By: Latest Listings

For both of the two cells, I need to split their label and content. 对于这两个单元格,我需要拆分其标签和内容。 So for the first cell, it would be (assuming the content beside | are two cells): 因此,对于第一个单元格,它将是(假设|旁边的内容是两个单元格):

Industry Type: | 行业类型: Home & Garden,Import/Export/Wholesale, | 家居与园艺,进口/出口/批发,| Location: | 位置: Auckland,Hawkes Bay,Wellington, | 奥克兰,霍克斯湾,惠灵顿,| PriceRange: | PriceRange:| $250,000 to $400,000, | $ 250,000至$ 400,000,| Order By: | 订购依据:| Latest Listings 最新清单

How do I split text with both string and semicolon? 如何用字符串和分号分割文本?

If your data is always in the same order (Industry Type, Location, PriceRange and Order By), you could use a series of formulas to extract. 如果您的数据始终是相同的顺序(行业类型,位置,价格范围和订购依据),则可以使用一系列公式来提取。

Cell B1 enter: 单元格B1输入:

=LEFT(RIGHT(A1, LEN(A1)-15),FIND(", Location",RIGHT(A1,LEN(A1)-15))-1)

Cell C1 enter: 单元格C1输入:

=LEFT(RIGHT(A1,LEN(A1)-SUM(15,LEN(B1),12)),FIND(", Price",RIGHT(A1,LEN(A1)-SUM(15,LEN(B1),12)))-1)

Cell D1 enter: 单元格D1输入:

=LEFT(RIGHT(A1,LEN(A1)-SUM(15,LEN(B1),12,LEN(C1),14)),FIND(", Order",RIGHT(A1,LEN(A1)-SUM(15,LEN(B1),12,LEN(C1),14)))-1)

Cell E1 enter: 单元格E1输入:

=RIGHT(A1,LEN(A1)-SUM(15,LEN(B1),12,LEN(C1),14,LEN(D1),12))

Then copy all the formulas down for all your information. 然后复制所有公式以获取所有信息。

It's possible to clean this up a bit with some named ranges, or even VBA, but this will get the job done. 可以使用一些命名范围甚至VBA对此进行一些清理,但这可以完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM