Excel RANDOM(下划线后)后缀删除

时间:2017-06-09 16:49:31

标签: excel excel-vba vba

我有一列信息,某些条目以下划线结尾,后跟一位或两位数字,如下所示:

b_labla_bla_67

afdsfsfwer_8

fasd_dfd_fda

关于这一点的复杂部分是下划线也在其他地方的单元格中使用,但基本上,如果最后一个下划线后跟一个数字,则需要将其删除。

有没有办法为此编写脚本?

编辑:单元格的其余部分没有任何数字,只有后缀。因此,我能够使用

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE _
 (SUBSTITUTE(SUBSTITUTE(SUBSTITUTE _ 
  (D2,"1",""),"0",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9","")

1 个答案:

答案 0 :(得分:0)

试试这个公式,

=IF(ISNUMBER(VALUE(RIGHT(A1))),LEFT(A1,FIND("#",SUBSTITUTE(A1,"_","#",LEN(A1)-LEN(SUBSTITUTE(A1,"_",""))))-1),A1)

enter image description here

如果您希望最后_留在文字上,请从公式中删除-1