Dear all,
I am trying to write a VBA code that first identifies a string of text that has no text behind it. Then, it would add some text once the two conditions are fulfilled.
For example, I am trying to replace "P - " with "P - None". However, it should not become "P- Nonexxxxxxxx" if there are text behind.
I have only managed to write the first set of condition but I am struggling with the second, that won't interfere if there some text behind.
Any guidance or help is greatly appreciated!
I am trying to write a VBA code that first identifies a string of text that has no text behind it. Then, it would add some text once the two conditions are fulfilled.
For example, I am trying to replace "P - " with "P - None". However, it should not become "P- Nonexxxxxxxx" if there are text behind.
I have only managed to write the first set of condition but I am struggling with the second, that won't interfere if there some text behind.
VBA Code:
Dim i As Long
For i = 5 To Cells(Rows.Count, "F").End(xlUp).Row
If InStr(Cells(i, "F").Value, "P -") > 0 Then
Cells(i, "F").Replace What:="P -", Replacement:="P - None"
Any guidance or help is greatly appreciated!