跳到主要内容

如何在Excel中第二个空格或逗号之前/之后提取文本? 

在Excel中,“文本到列”功能可以帮助您按空格,逗号或其他定界符将一个单元格中的每个文本提取到单独的单元格中,但是,您是否曾经尝试从一个单元格中提取第二个空格或逗号之前或之后的文本在Excel中,如下所示的屏幕截图? 本文中,我将讨论一些处理此任务的方法。

doc提取第二个空格之前1

用公式在第二个空格或逗号之前提取文本

用公式在第二个空格或逗号后提取文本


箭头蓝色右气泡 用公式在第二个空格或逗号之前提取文本

要在第二个空格之前获取文本,请应用以下公式:

输入以下公式: = IF(ISERROR(FIND(“”,A2,FIND(“”,A2,1)+1)),A2,LEFT(A2,FIND(“”,A2,FIND(“”,A2,1)+1 ))) 放入要查找结果的空白单元格中, C2,例如,然后将填充手柄向下拖动到要包含此公式的单元格,然后从每个单元格中提取第二个空格之前的所有文本,请参见屏幕截图:

doc提取第二个空格之前2

备注:如果要提取第二个逗号或其他分隔符之前的文本,请根据需要将公式中的空格替换为逗号或其他分隔符。 如: =IF(ISERROR(FIND(",",A2,FIND(",",A2,1)+1)),A2,LEFT(A2,FIND(",",A2,FIND(",",A2,1)+1))).


箭头蓝色右气泡 用公式在第二个空格或逗号后提取文本

要在第二个空格后返回文本,以下公式可以为您提供帮助。

请输入以下公式: = MID(A2,FIND(“”,A2,FIND(“”,A2)+1)+1,256) 到一个空白单元格中以找到结果,然后将填充手柄向下拖动到这些单元格以填充此公式,并且立即提取了第二个空格之后的所有文本,请参见屏幕截图:

doc提取第二个空格之前3

请注意: 如果要提取第二个逗号或其他分隔符之后的文本,则只需要根据需要在公式中用逗号或其他定界符替换空格。 如: = MID(A2,FIND(“,”,A2,FIND(“,”,A2)+1)+1,256).

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (28)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, I want to extract each values after underscore. How do I do that. I am familiar with delimiter, but want to learn the formula to do that.

Brush_25mm_Orange_Skid_110cm
Polish_25mm_Orange_Toast_100cm
Car_25mm_White_Tyre_120cm
Paint_25mm_Red_Reflective_95cm
This comment was minimized by the moderator on the site
Edit - I see this was already addressed by Dave - thank you sir! skyyang can you please edit the incorrect solution to "Extract Text Before The Second Delimiter" with the correct equation logic?
This comment was minimized by the moderator on the site
Hello There

I have a scenario in 4 types as below in a excel chart

Type 1 : FX01865-CWB-22F
Type 2 : CD30250-AJX-2D-AB
Type 3 : DF10250-MUR-JH-B
Type 4 : YZ00250-MDS-4T-BHR

To all cases, I want to extract only the BOLD TEXT as an answer in the adjacent cells

Please help share formula

ThanksSaran

This comment was minimized by the moderator on the site
I have the text like this
LAXMI RANI DELHI DELHI CG012054567IN CA
so, I want the text to be arranged in excel like this
LAXMI RANI(1st cell ) DELHI(2nd cell) DELHI (3rd cell) CG012054567IN (4th cell) CA(5th cell)
This comment was minimized by the moderator on the site
Hi, rangaih,To deal with your problem, first, you can split your cell values based on space by using the Text to Columns feature, after spliting the text strings, you just need to combine the fisrt two cell values as you need.Please try, thank you!
This comment was minimized by the moderator on the site
Hi, I have a long string in a single cell and want to extract all the information after each Product ID. Product ID: 686, Product Qty: 1, Product SKU: RUB 100, Product Name: Emu Oil Rub 100g, Product Weight: 0.2000, Product Variation Details: |Product ID: 691, Product Qty: 1, Product SKU: MOIST 100, Product Name: Emu Oil Moisturiser 100g, Product Weight: 0.1900, Product Variation Details: , |Product ID: 705, Product Qty: 3, Product SKU: WASH 250, Product Name: Natural Hand & Body Wash with Emu Oil 250ml, Product Weight: 0.4000, Product Variation Details: I need the quantity in one cell and the product name in another cell for each of the products after Product ID. Can you help?
This comment was minimized by the moderator on the site
In my scenario There are three “-“ and sometimes one “-“
before second “-“ text should be enter
if in cell only one “-“ it should be blank

e.g As-01-14-32 answers like thisAs-01

e.g As-01 answer Blank cell

what will be farmula?
This comment was minimized by the moderator on the site
Hello, Bil,
To solve your problem, please apply the below formula:
=IFERROR(LEFT(A1,FIND("#",SUBSTITUTE(A1,"-","#",2))-1),"")
Please try it, thank you!
This comment was minimized by the moderator on the site
Hi
I need help if i want to extract anything after first comma and before last comma.
"Flat 135 Nevendon Road, Sally,Wickford, SS12 0NL"

Column A = Flat 135 Nevendon Road
Column B = Sally,Wickford
Columns C = SS12 0NL
This comment was minimized by the moderator on the site
Hello, Jayaswal,
To solve your porblem, please apply the following formulas:
First part--Cell B1: =LEFT(A1,FIND(",",A1,1)-1)
Second part--Cell C1: =MID(A1,FIND(",",A1)+1,LOOKUP(1,0/(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)=","),ROW(INDIRECT("1:"&LEN(A1))))-FIND(",",A1)-1)
Third part--Cell D1: =MID(A1,FIND("=",SUBSTITUTE(A1,",","=",LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))+1,256)

Pleasr try, hope it can help you!
This comment was minimized by the moderator on the site
It’s working, thanks
This comment was minimized by the moderator on the site
One more thing
after third”-“all text should remain even 1 or 10 otherwise blank
e.g A-01-12-As answer As
e.g A-01-12-Asty answer Asty
e.g A-01 answer blank
This comment was minimized by the moderator on the site
Hi,
May be the below formula can solve your task, please try:
=IFERROR(TRIM(MID(A1,FIND("#",SUBSTITUTE(A1,"-","#",3))+1,255)),"")
This comment was minimized by the moderator on the site
Fine thanks
This comment was minimized by the moderator on the site
How can I extract Text 1 and Text 2 from a string like Text 1_Text 2_Text 3_Text 4
This comment was minimized by the moderator on the site
how do I do this from right to left. Basically, want to extract last two words.
This comment was minimized by the moderator on the site
Hi, demo,
To extract and return the last two words from text strings, please apply the below formula:
=IF((LEN(A1)-LEN(SUBSTITUTE(A1," ","")))<2,A1,RIGHT(A1,LEN(A1)-FIND("/",SUBSTITUTE(A1," ","/",(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1)))))

Please try, hope it can help you!
This comment was minimized by the moderator on the site
THANK YOU!!!
This comment was minimized by the moderator on the site
Is there a way to extract various pieces of this string? 123ABC.01.02.03.04 ---- for example, to pull the 123ABC, and then in the next column pull 123ABC.01, and then 123ABC.01.02, then 123ABC.01.02.03, and so on.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations