例如,在单元格A1中,我可能有“区域经理助理”。我最初的想法就是像这样使用Instr:
If InStr(1, Cells(x, 1).Value, "Assistant") > 0 Then
Cells(x, 1).Value = Cells(x, 1).Value - "Assistant to the "
所以只剩下“区域经理”,但这不起作用。有没有办法删除“助理”?
答案 0 :(得分:3)
怎么样?
Cells(x, 1).Value = Replace(Cells(x, 1).Value, "Assistant to the ", "")
答案 1 :(得分:1)
有多种方法可以达到你想要的效果
Replace
:FoxInCloud已经涵盖了这一点。 < ==这是最简单的。 Split
:
Debug.Print Split(Cells(x, 1).Value,"Assistant to the ")(1)
Mid/Len
:
Debug.Print Mid(Cells(x, 1).Value, Len("Assistant to the ") + 1, _
Len(Cells(x, 1).Value) - Len("Assistant to the "))
Right/Len
:
Debug.Print Right(Cells(x, 1).Value, Len("Assistant to the "))
我强烈建议您花一些时间研究这些功能如何运作以获得更好的想法。