如何从单元格中删除特定的文本

例如,在A1单元格中,我可能会有“区域经理助理”。 我最初的想法是像这样使用Instr:

If InStr(1, Cells(x, 1).Value, "Assistant") > 0 Then Cells(x, 1).Value = Cells(x, 1).Value - "Assistant to the " 

所以只有“区域经理”仍然存在,但这是行不通的。 有没有办法删除“助手”?

关于什么

 Cells(x, 1).Value = Replace(Cells(x, 1).Value, "Assistant to the ", "") 

有各种方式来实现你想要的

  1. Replace :FoxInCloud已经覆盖了。 <==这是最简单的
  2. Split

     Debug.Print Split(Cells(x, 1).Value,"Assistant to the ")(1) 
  3. Mid/Len

     Debug.Print Mid(Cells(x, 1).Value, Len("Assistant to the ") + 1, _ Len(Cells(x, 1).Value) - Len("Assistant to the ")) 
  4. Right/Len

     Debug.Print Right(Cells(x, 1).Value, Len("Assistant to the ")) 

我强烈build议你花一些时间研究这些function如何工作,以获得更好的想法。