Search code examples
excelexcel-2013vba

How to remove specific text from a cell


So for example, in cell A1 I might have "Assistant to the Regional Manager." My original idea was to use Instr like this:

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

so that only "Regional Manager" remains, but this does not work. Is there a way to remove "Assistant to the "?


Solution

  • What about

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