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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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