Formula IF...begins with...possible?

j844929

Active Member
Joined
Aug 18, 2002
Messages
423
Hi,

Does anyone know if there is a way of writing a formula that will show certain values depending upon the first piece of text in another cell...?

What I'd like to do, is the following:

IF cell A1 begins with C, replace 'C' with 'T' can it be done? (There are only ever two characters in the cell. I can do it so that no matter what the cell begins with, it is replaced with a 'T', but I need to make it conditional...

Any suggestions would be appreciated.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi, I guess:

=IF(LEFT(A1)="C","T"&RIGHT(A1),A1)

but if C cannot appear as second letter you could use

=SUBSTITUTE(A1,"C","T")
 
Upvote 0
Actually, I've had another thought. There are a few instances where the referenced cell begins with 'T' and not 'C'. Any ideas on using an IF(AND( statement to do the calculation the other way round as well, but combine the two into one cell...?

ie. If the cell begins with 'T', replace with 'C' but if it begins with 'C', replace with 'T'........
 
Upvote 0
Another variation on fairwind's first substitute...
=IF(LEFT(A1)="C",SUBSTITUTE(A1,"C","T"),IF(LEFT(A1)="T",SUBSTITUTE(A1,"T","C")))
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,956
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top