+ Reply to Thread
Results 1 to 5 of 5

If number starts with X, do Y.

  1. #1
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    If number starts with X, do Y.

    Named Ranges:

    Ranges with multiple cells, each containing a specific prefix.
    GREATNUMS
    OKNUMS


    Ranges consisting of a single cell, with a single number in it.
    GREATVALUE
    OKVALUE
    OTHER



    Column A consists of long numbers - one in each cell. I want Excel to see if those numbers start with specific prefixes and assign a value depending on what prefix it is.

    Requirements:
    If the number starts with any value listed in the GREATNUMS range, the formula spits out the number in the GREATVALUE cell.
    If the number starts with any value listed in the OKNUMS range, the formula spits out the number in the OKVALUE cell.
    If the number does not start with any prefixes in the GREATNUMS or OKNUMS ranges, the formula spits out the number in the OTHER cell.

    (The formula would have to account for the fact that the prefixes are different sizes - some are two digits, and some are three digits)


    I have tried doing this with a lot of IF-LOOKUP-SEARCH statements, but the formula is beginning to be EXTREMELY long (like close to 1,000 characters), which is ridiculous for such a simple operation. There's gotta be a better way. ??

    (EDIT: I have attached an example spreadsheet in comment #3.)

    Thanks!
    Last edited by daedelous00; 08-13-2013 at 12:35 PM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,611

    Re: If number starts with X, do Y.

    Please post a sample sheet - Thx

  3. #3
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: If number starts with X, do Y.

    Attached. Looking for appropriate values to be inserted into column B.
    Attached Files Attached Files

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: If number starts with X, do Y.

    In B2

    =IF(SUMPRODUCT(--(LEFT(A2,LEN(greatnums))*1=greatnums)),greatvalue,IF(SUMPRODUCT(--(LEFT(A2,LEN(oknums))*1=oknums)),okvalue,othervalue))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: If number starts with X, do Y.

    I love you...Thanks!

+ 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: 1
    Last Post: 05-17-2013, 04:56 AM
  2. [SOLVED] Sorting of a Log Number that starts with a two digit year
    By xltbob in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-19-2012, 05:34 PM
  3. if number starts then equal (something like that)
    By xelan in forum Excel General
    Replies: 6
    Last Post: 12-18-2007, 03:11 PM
  4. Zero starts of a number
    By Lisa in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-09-2006, 04:55 PM
  5. [SOLVED] Delete file if it starts with a number
    By Michael Smith in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2006, 01:15 PM

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