+ Reply to Thread
Results 1 to 9 of 9

LEN formula needed

  1. #1
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    LEN formula needed

    Hi,
    Not sure this is possible but I need a formula or macro, not Conditional Formatting, to do the following:

    Column D, rows 1 to 3, contains one of the following choices (or a variation)

    PP317181027CA
    NR
    2KAK030731045327775245600000

    In Column C, rows 1-3, I would need to see the following result:

    Row 1 - PP317181027CA
    Row 2 - NR
    Row 3 - 7310453277752456

    Sorry, I am terrible with formulas and all I can manage is -
    =LEN(d1)>25 but of course all it gives me is a true or false

    But what I need is, if the length is greater than 25 I need the first 7 and last 5 numbers removed and the remaining value in the cell in column C -
    from 2KAK030731045327775245600000 to 7310453277752456

    If its less than 25 characters (as in Row 1 and 2 above) I need those complete values in C1 and C2

    Any help would be greatly appreciated and apologies in advance if my explanation/problem is confusing.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: LEN formula needed

    post withdrawn
    Last edited by humdingaling; 05-26-2016 at 08:56 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,414

    Re: LEN formula needed

    Put this formula in C1:

    =IF(LEN(D1)>25,MID(D1,8,16),D1)

    then copy down.

    Hope this helps.

    Pete

  4. #4
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: LEN formula needed

    You, my kind Sir, are freaking awesome. Works perfectly! Exactly what I need. Thank you so much for replying, especially so quickly. Would you mind explaining the 8 + 16 to me, if you don't mind.

    Brenda

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,176

    Re: LEN formula needed

    Quote Originally Posted by BDD2015 View Post
    I need the first 7 and last 5 numbers removed
    Try this ...

    =IF(LEN(D1)>25,MID(D1,8,LEN(D1)-12),D1)

  6. #6
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: LEN formula needed

    Hi,
    Thanks
    I just picked 25 because those numbers definitely exceed 25
    but I just needed it to be 7310453277752456 which means getting rid of the first 7 and last 5
    Appreciate your interest but Pete_UK offered me a perfect formula.
    But thanks so much.
    Brenda

  7. #7
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: LEN formula needed

    Thank you!
    Pete_UK already gave me a formula that works but this works great too.
    I will be looking at both so I can understand the logic.
    Thank you for your help.
    Regards, Brenda

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: LEN formula needed

    http://www.techonthenet.com/excel/formulas/mid.php

    this is how Mid works
    MID( text, start_position, number_of_characters )
    so 8 is the start position

    with number of characters
    in pete's example it is a fixed 16 characters
    in phuo's example Length of text (28) - 12 (7+5) = 28-12 =16
    Last edited by humdingaling; 05-26-2016 at 09:15 PM.

  9. #9
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: LEN formula needed

    Thank you. That makes it much clearer. Appreciate your time.

    Brenda

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 04-06-2016, 12:19 PM
  2. Replies: 1
    Last Post: 01-11-2016, 02:31 PM
  3. [SOLVED] Formula needed to depend formula's range on specified cells
    By VincentNL in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-01-2014, 06:15 AM
  4. Replies: 7
    Last Post: 02-03-2013, 06:25 PM
  5. Replies: 16
    Last Post: 10-19-2012, 08:48 PM
  6. [SOLVED] index formula needed--how to get a formula to skip columns
    By rsmidtisu in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-02-2012, 11:22 AM
  7. Replies: 3
    Last Post: 09-07-2012, 12:07 AM

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