If 5th character="-" delete everything to the left otherwise do no

  • Thread starter Thread starter Mike R.
  • Start date Start date
M

Mike R.

Hi -
I can't seem to figure this out, I bet it is pretty easy. Can anyone assist?

The text is in A1.

Thanks,
Mike
 
You really should put your main question in the white box, not in the header.

=IF(LEN(A1)<5,A1,IF(MID(A1,5,1)="-",RIGHT(A1,LEN(A1)-5),A1))
 
Firstly, please ask the question in the body of the message. If you ask it
in the subject line, as you tried to do, it will probably be trunc.....

By "do no", do you mean include A1 unaltered?
By "delete everything to the left" do you mean that you want to output
everything to the right of the hyphen?

Try =IF(MID(A1,5,1)="-",MID(A1,6,9999),A1)
If you want to include the hyphen in the output, and just lose the preceding
4 characters, then try
=IF(MID(A13,5,1)="-",MID(A13,5,9999),A13)
 
=MID(A1,IF(MID(A1,5,1)="-",6,1),99)

Stated another way...

=MID(A1,1+5*(MID(A1,5,1)="-"),99)
 
Back
Top