使用 Excel 公式将单元格拆分为多列 [英] Split cells in several columns with Excel formulas

查看:40
本文介绍了使用 Excel 公式将单元格拆分为多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下内容的单元格:

 A1 文字 1;文字 2;文字 3;文字 4;文字 5

我想把它分成五个单元格,每次出现一个;,就像这样:

 B C D E F1 文字1 文字2 文字3 文字4 文字5

我知道 Excel 有文本到列"功能,但我需要将其自动化,所以这不是一个选项.我已经在 B1 中输入了这个:

=left(A1;FIND(";";A1;1)-1)

这让我text1,这就是我想要的.对于下一个单元格,我需要 text2.我试过这个:

=right(A1;len(A1)-len(B1)-1)

我的工作表现在看起来像这样:

 B C1 文字 1 文字 2;文字 3;文字 4;文字 5

我现在的问题是,我需要删除第一个 ; 之后的所有内容,但我似乎无法弄清楚.有什么想法吗?

解决方案

如果您想要一个等效于 Text to Columns 的公式并且 A1 包含要解析的文本,那么在 B1 中输入:

=TRIM(MID(SUBSTITUTE($A1,";",REPT(" ",999)),COLUMNS($A:B)*999-998,999)) 并复制.

I have a cell with the following content:

     A
1    text1;text2;text3;text4;text5

I'd like to divide it into five cells, one for each occurrence of ;, like this:

     B      C      D      E      F
1    text1  text2  text3  text4  text5

I know Excel has a "Text to columns" function, but I need this to be automated, so that's not an option. I've entered this in B1:

=left(A1;FIND(";";A1;1)-1)

This gets me text1, which is what I want. For the next cell I need text2. I've tried this:

=right(A1;len(A1)-len(B1)-1)

My sheet now looks like this:

     B      C
1    text1  text2;text3;text4;text5

My issue now is, that I need to remove everything after the first ;, but I can't seem to figure it out. Any ideas?

解决方案

If you want a formula equivalent to Text to Columns and A1 contains the text to be parsed, then in B1 enter:

=TRIM(MID(SUBSTITUTE($A1,";",REPT(" ",999)),COLUMNS($A:B)*999-998,999)) and copy across.

这篇关于使用 Excel 公式将单元格拆分为多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆