+ Reply to Thread
Results 1 to 8 of 8

Help with formula to return a number based on number string

  1. #1
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Help with formula to return a number based on number string

    Hi

    I have a bunch of numbers in a list like this:

    45
    13
    123
    123x
    12x1
    1x21
    x213
    1
    5x13

    I am trying to write a formula to determine if there is a 1 in the last 3 values of the cell, e.g. 123 would return 1 and 415 would return 1.

    The problem I have is that some values contain the letter "x".

    If the x is in the last place, I need to check the 3 values before this.
    If the x is in the 2nd last place, I need to check the 2 values before this.
    If the x is in the 3rd last place, I need to check the 1 value before this.
    If the x is at the beginning, I need to check the numbers that appear after it.

    If there are only 2 numbers in the cell, then the same applies (and it could also contain an "x").

    Can anyone assist with this?
    Last edited by maym; 12-10-2017 at 11:24 PM.

  2. #2
    Registered User
    Join Date
    06-03-2015
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    34

    Re: Help with formula to return a number based on number string

    Hi,

    You can use formula like
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It will return 1 if there is 1 present in cell.

    Cheers
    Last edited by arunsjain; 12-10-2017 at 11:46 PM.

  3. #3
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Help with formula to return a number based on number string

    Hi all. Assuming values in column A:
    Please Login or Register  to view this content.
    ...or perhaps just:
    Please Login or Register  to view this content.
    ...if you don't need to restrict it to the last 3 characters.
    Last edited by leelnich; 12-10-2017 at 11:40 PM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  4. #4
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Help with formula to return a number based on number string

    thank you, these are great.

    lee - one of my cells has 4 values, "1234" so it returned 0. How can I adjust to return 1?

  5. #5
    Registered User
    Join Date
    06-03-2015
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    34

    Re: Help with formula to return a number based on number string

    Hi Maym,

    Try this one
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    It will give you 1 irrespective of digit in cell. If 1 present then you will get 1..
    Last edited by arunsjain; 12-10-2017 at 11:46 PM.

  6. #6
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Help with formula to return a number based on number string

    Perhaps just:
    Please Login or Register  to view this content.
    ...if you don't need to restrict it to the last 3 characters (in which case, the "x" may be ignored.)

  7. #7
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Help with formula to return a number based on number string

    excellent, thank you both

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Help with formula to return a number based on number string

    You're most welcome, thank you for the rep!

+ 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. how to structure formula to return an amt based on number and text
    By Iappreciate in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-24-2016, 09:51 AM
  2. Replies: 2
    Last Post: 01-28-2015, 09:07 AM
  3. Replies: 9
    Last Post: 03-06-2014, 04:48 PM
  4. [SOLVED] Formula to return score of 0-100 based on column of number data?
    By theronager in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-22-2013, 06:45 PM
  5. [SOLVED] Add number sequentially to string based on formula
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-09-2012, 11:19 AM
  6. Replies: 3
    Last Post: 03-29-2012, 05:28 PM
  7. Replies: 1
    Last Post: 01-26-2012, 07:16 AM

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