+ Reply to Thread
Results 1 to 7 of 7

How do I trim cell values

  1. #1
    Jeremy Turner
    Guest

    How do I trim cell values

    Hi

    I have a column of cells each containing a 4 digit number. Is there any way
    I can trim the left digit dependant upon certain conditions.

    If the left digit of each 4 digit number equals either "1" or "2" I want to
    trim this away. If the original 4 digit number ends in anything other than
    "1" or "2" I want to leave the original 4 digit number unaltered.

    For example:

    1231 would become 123
    1232 would become 123
    1234 would stay as 1234

    Any help on this is really appreciated.

    Many thanks in advance

    Jem



  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Assuming your data is in A1

    =IF(OR(LEFT(A1,1)="1",LEFT(A1,1)="2"),RIGHT(A1,3),A1)

  3. #3
    Bob Phillips
    Guest

    Re: How do I trim cell values

    =--LEFT(A1,LEN(A1)-(OR(RIGHT(A1)="1",RIGHT(A1)="2")))

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Jeremy Turner" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > I have a column of cells each containing a 4 digit number. Is there any

    way
    > I can trim the left digit dependant upon certain conditions.
    >
    > If the left digit of each 4 digit number equals either "1" or "2" I want

    to
    > trim this away. If the original 4 digit number ends in anything other

    than
    > "1" or "2" I want to leave the original 4 digit number unaltered.
    >
    > For example:
    >
    > 1231 would become 123
    > 1232 would become 123
    > 1234 would stay as 1234
    >
    > Any help on this is really appreciated.
    >
    > Many thanks in advance
    >
    > Jem
    >
    >




  4. #4
    Toppers
    Guest

    RE: How do I trim cell values

    =IF(OR(RIGHT(A1)=1,RIGHT(A1)=2),LEFT(A1,3),A1)

    "Jeremy Turner" wrote:

    > Hi
    >
    > I have a column of cells each containing a 4 digit number. Is there any way
    > I can trim the left digit dependant upon certain conditions.
    >
    > If the left digit of each 4 digit number equals either "1" or "2" I want to
    > trim this away. If the original 4 digit number ends in anything other than
    > "1" or "2" I want to leave the original 4 digit number unaltered.
    >
    > For example:
    >
    > 1231 would become 123
    > 1232 would become 123
    > 1234 would stay as 1234
    >
    > Any help on this is really appreciated.
    >
    > Many thanks in advance
    >
    > Jem
    >
    >
    >


  5. #5
    CLR
    Guest

    RE: How do I trim cell values

    There appears to be a conflict between your description and your example.
    This formula will return results in accordance with your Example..........

    =IF(OR(RIGHT(A1,1)="1",RIGHT(A1,1)="2"),LEFT(A1,LEN(A1)-1),A1)*1

    Vaya con Dios,
    Chuck, CABGx3

    "Jeremy Turner" wrote:

    > Hi
    >
    > I have a column of cells each containing a 4 digit number. Is there any way
    > I can trim the left digit dependant upon certain conditions.
    >
    > If the left digit of each 4 digit number equals either "1" or "2" I want to
    > trim this away. If the original 4 digit number ends in anything other than
    > "1" or "2" I want to leave the original 4 digit number unaltered.
    >
    > For example:
    >
    > 1231 would become 123
    > 1232 would become 123
    > 1234 would stay as 1234
    >
    > Any help on this is really appreciated.
    >
    > Many thanks in advance
    >
    > Jem
    >
    >
    >


  6. #6
    Jeremy Turner
    Guest

    Re: How do I trim cell values

    Many thanks for everyones prompt responses. It really is appreciated.

    Cheers

    Jem


    "CLR" <[email protected]> wrote in message
    news:[email protected]...
    > There appears to be a conflict between your description and your example.
    > This formula will return results in accordance with your Example..........
    >
    > =IF(OR(RIGHT(A1,1)="1",RIGHT(A1,1)="2"),LEFT(A1,LEN(A1)-1),A1)*1
    >
    > Vaya con Dios,
    > Chuck, CABGx3
    >
    > "Jeremy Turner" wrote:
    >
    >> Hi
    >>
    >> I have a column of cells each containing a 4 digit number. Is there any
    >> way
    >> I can trim the left digit dependant upon certain conditions.
    >>
    >> If the left digit of each 4 digit number equals either "1" or "2" I want
    >> to
    >> trim this away. If the original 4 digit number ends in anything other
    >> than
    >> "1" or "2" I want to leave the original 4 digit number unaltered.
    >>
    >> For example:
    >>
    >> 1231 would become 123
    >> 1232 would become 123
    >> 1234 would stay as 1234
    >>
    >> Any help on this is really appreciated.
    >>
    >> Many thanks in advance
    >>
    >> Jem
    >>
    >>
    >>




  7. #7
    Jeremy Turner
    Guest

    Re: How do I trim cell values

    Oop's... That's me not knowing my right from left ;-)

    Thanks for the help, i've now got it sorted.

    Cheers

    Jem

    "CLR" <[email protected]> wrote in message
    news:[email protected]...
    > There appears to be a conflict between your description and your example.
    > This formula will return results in accordance with your Example..........
    >
    > =IF(OR(RIGHT(A1,1)="1",RIGHT(A1,1)="2"),LEFT(A1,LEN(A1)-1),A1)*1
    >
    > Vaya con Dios,
    > Chuck, CABGx3
    >
    > "Jeremy Turner" wrote:
    >
    >> Hi
    >>
    >> I have a column of cells each containing a 4 digit number. Is there any
    >> way
    >> I can trim the left digit dependant upon certain conditions.
    >>
    >> If the left digit of each 4 digit number equals either "1" or "2" I want
    >> to
    >> trim this away. If the original 4 digit number ends in anything other
    >> than
    >> "1" or "2" I want to leave the original 4 digit number unaltered.
    >>
    >> For example:
    >>
    >> 1231 would become 123
    >> 1232 would become 123
    >> 1234 would stay as 1234
    >>
    >> Any help on this is really appreciated.
    >>
    >> Many thanks in advance
    >>
    >> Jem
    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1