简体   繁体   English

Excel - 从列中删除第一个第 n 个破折号并保留最后一个

[英]Excel - Remove the first nth Dashes from a column and leave the last

I have data in a column like this.我在这样的列中有数据。 I need to remove all the dashes with the exception of the last, right dash.除了最后一个右破折号外,我需要删除所有破折号。

So data in the column like this:所以列中的数据如下:

QQQ-NE
Q-A-123-N
Q-B-234-BE
Q-BB-999-RW

To this对此

 QQQ-NE
 QA123-N
 QB234-BE
 QBB999-RW

I assume I use SUBSTITUTE() .我假设我使用SUBSTITUTE() But how I can just leave the last dash?但是我怎么能留下最后的破折号呢?

Thanks in advance提前致谢

Probably can be simplified, but some nested SUBSTITUTEs works:可能可以简化,但一些嵌套的 SUBSTITUTE 有效:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"-","~",LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))),"-",""),"~","-")

在此处输入图像描述

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

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