Hi everyone
I have a problem to trim the left characters of a cell, if the column E cell value starts with P or M, then the first left two characters have to trim off, if it starts with X, then the left four characters have to trim off.
I have done the vba as follows but it doesn't work, please can anyone help?
I have a problem to trim the left characters of a cell, if the column E cell value starts with P or M, then the first left two characters have to trim off, if it starts with X, then the left four characters have to trim off.
I have done the vba as follows but it doesn't work, please can anyone help?
HTML:
Dim i As Long
Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, 5).Value Like "P-*" Or Cells(i, 5).Value Like "M-*" Then
Cells(i, 5).value = Right((i,5), Len((i,5) - 2)
Else
If Cells(i, 5).Value Like "Z*" Then Cells(i, 5).Value = Right((i,5), Len(i,5) - 4)
End If
End If
Next I