A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

combining =SEARCH & =IF statements



 
 
Thread Tools Display Modes
  #1  
Old February 5th, 2010, 06:15 PM posted to microsoft.public.excel.worksheet.functions
McRibIsBack
external usenet poster
 
Posts: 12
Default combining =SEARCH & =IF statements

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!
  #2  
Old February 5th, 2010, 06:39 PM posted to microsoft.public.excel.worksheet.functions
Teethless mama
external usenet poster
 
Posts: 3,722
Default combining =SEARCH & =IF statements

In B1: =REPLACE(SUBSTITUTE(SUBSTITUTE(A1," ",),"-",),6,,"-")

copy down


"McRibIsBack" wrote:

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!

  #3  
Old February 5th, 2010, 06:46 PM posted to microsoft.public.excel.worksheet.functions
McRibIsBack
external usenet poster
 
Posts: 12
Default combining =SEARCH & =IF statements

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!!!!

"Teethless mama" wrote:

In B1: =REPLACE(SUBSTITUTE(SUBSTITUTE(A1," ",),"-",),6,,"-")

copy down


"McRibIsBack" wrote:

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!

  #4  
Old February 5th, 2010, 06:52 PM posted to microsoft.public.excel.worksheet.functions
McRibIsBack
external usenet poster
 
Posts: 12
Default combining =SEARCH & =IF statements

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

"Teethless mama" wrote:

In B1: =REPLACE(SUBSTITUTE(SUBSTITUTE(A1," ",),"-",),6,,"-")

copy down


"McRibIsBack" wrote:

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!

  #5  
Old February 5th, 2010, 07:26 PM posted to microsoft.public.excel.worksheet.functions
Teethless mama
external usenet poster
 
Posts: 3,722
Default combining =SEARCH & =IF statements

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


"McRibIsBack" wrote:

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

"Teethless mama" wrote:

In B1: =REPLACE(SUBSTITUTE(SUBSTITUTE(A1," ",),"-",),6,,"-")

copy down


"McRibIsBack" wrote:

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!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.