+ Reply to Thread
Results 1 to 3 of 3

IF & LEN together

  1. #1
    Registered User
    Join Date
    08-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    14

    IF & LEN together

    Hello,

    I have a cell with 7 digits, but it may go up to 8 digits at anytime. I need to automatically either extract the 6 digits on the left of the 7 digits or the 7 digits from the left of the 8 digits.

    example:

    B1. 7634471 (I need just the 763447) =left(B1,6) works alone fine for 6, but what if it reads 76344719? I now need the 7634471. I tried the If and Len statement but it always only grabs the left 6 digits.

    Thanks for your help.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    41,270

    Re: IF & LEN together

    How about this?

    =LEFT(B1,LEN(B1)-1)

    However, you will need this to return a number rather than text:

    =--LEFT(B1,LEN(B1)-1)

    Excel 2016 (Windows) 32 bit
    B
    C
    1
    7634471
    763447
    2
    76344719
    7634471
    Sheet: Sheet1
    Last edited by AliGW; 07-28-2019 at 08:25 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  3. #3
    Banned User!
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: IF & LEN together

    Or you could try

    =INT(B1/10)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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