Spock
Spock

Reputation: 61

remove last value if a number otherwise do nothing

I am trying to find a formula for Microsoft Excel:

If the last value from a cell is a number then delete the value from the cell otherwise do leave the same content

=IF(OR((LEN(B2)>1),(LEN(B2)<7)),LEFT(B2, LEN(B2)-1),B2)

this is what I have tried but I am sure this is not the right way to do it, I have values where is 20152 and _thisform1 and _thisotherform so the length it is not the same for cells.

I would want to from from 20152 to 2015 and from _thisform1 to _thisform and leaving _thisotherform as is.

Upvotes: 0

Views: 173

Answers (1)

Scott Craner
Scott Craner

Reputation: 152465

Use this:

=IF(ISNUMBER(--RIGHT(B2)),LEFT(B2,LEN(B2)-1),B2)

Upvotes: 2

Related Questions