• Status: Solved
• Priority: Medium
• Security: Public
• Views: 213

# I would like to cut the first character of a string if it starts with a T in MS excel

I have a column of cells that have numbers in them.   Some start with a T and some don't.  I would like to cut the T from the cells that start with a T and leave the others alone.
0
dmalovich
• 3
• 3
• 2
• +1
1 Solution

ProgrammerCommented:
you could do something like this... if your data is in column A:

=IF(LEFT(A1,1)="T", MID(A1,2,LEN(A1)-1))
0

ProgrammerCommented:
i forgot the FALSE part of the IF...

Sorry for that, here's the modification:
=IF(LEFT(A1,1)="T", MID(A1,2,LEN(A1)-1), A1)

You could also add UPPER statement to make it work no mather if the T is capital or not, like this:
=IF(UPPER(LEFT(A1,1))="T", MID(A1,2,LEN(A1)-1), A1)
0

Commented:
(NFP)
The test will not be case sensitive, so there is no need for UPPER here, FYI.
0

ProgrammerCommented:
true rorya.  Thanks for advising me.  I've never noticed that but Excel doesn't seems to make the difference between "t" and "T" in this case.  I wonder why.

@dmalovich: use the 1st line of my last comment since the upper is not necessary.
=IF(LEFT(A1,1)="T", MID(A1,2,LEN(A1)-1), A1)
0

Author Commented:
You do have the answer for putting the formula in a cell.  I'm looping through values in vba and would like to chop off the T if its the first character and leave it as is if it is not. example vba

position = Worksheets("something").Cells(1, 1).Value

if position has a T as first character
then chop it off
end if

Is this possible?
0

Commented:
Here's another option.....

=REPLACE(A1,1,(LEFT(A1)="T"),"")

As Rory says that isn't case-sensitive so it will remove both "T" and "t" if one of those is first letter. If you do want case-sensitivity then this version will only remove T not t

=REPLACE(A1,1,EXACT(LEFT(A1),"T")+0,"")

regards, barry
0

Commented:
``````position = Worksheets("something").Cells(1, 1).Value

if UCase(Left(position, 1)) = "T" then
position = MID\$(position, 2)
Worksheets("something").Cells(1, 1).Value = position
end if
``````

for example.
0

Author Commented:
Awesome.  Thanks....
0

Commented:
Since you didn't specify VBA in the original question, I think a points split would be more appropriate here?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

• 3
• 3
• 2
• +1
Tackle projects and never again get stuck behind a technical roadblock.