combining =SEARCH & =IF statements

M

McRibIsBack

hello, I have a simple task i think, but i need some guidance!

I have 3 Cells:
A1: 12345 - 67891
A2: 12345-67891
A3: 1234567891

Here are the things I want to do:
1) Remove all spaces
2)IF the cell already has a hyphen, do nothing
3)IF the cell does not have a hyphen, insert one at approximately 5
character positions from the right.

I know how to do all of these in their own cells, but I want to combine all
of the =SEARCH, =IF, =SUBSTITUTE/REPLAC etc. into one cell so the data looks
like this:

A1: 12345-67891
A2: 12345-67891
A3: 12345-67891

Thank you in advance!
 
M

McRibIsBack

hey thanks! For not having teeth, your formulas carry quite a bite. I've
never nested functions like these, so I'll stare at this for a bit so I can
understand it. Works brilliantly, thanks again!!!!
 
M

McRibIsBack

hey only one small thing. I need the hyphen inserted from 5 character
positions from the right, but this inserts it 5 from the left.

A1: 123-45675 is being turned into: 12345-675.

Can I toss an IF or SEARCH statement in there to do nothing if a "-" is
found?

thanks again
 
T

Teethless mama

=REPLACE(SUBSTITUTE(SUBSTITUTE(A1," ",),"-",),LEN(SUBSTITUTE(SUBSTITUTE(A1,"
",),"-",))-4,,"-")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top