+ Reply to Thread
Results 1 to 7 of 7

Formula to identify between whole numbers and numbers with decimals

Hybrid View

  1. #1
    Registered User
    Join Date
    01-28-2019
    Location
    Scotland
    MS-Off Ver
    Excel 2016
    Posts
    4

    Formula to identify between whole numbers and numbers with decimals

    Hi, I am in need of a formula which can distinguish between whole numbers and decimals in a column and from there subtract/add a value based on the number. E.g number = 80 then +/- 2.5, number = 80.0 then +/- 0.8, number = 80.00 then +/- 0.38

    Any help would be great and I can try my best to explain/clear anything up.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,872

    Re: Formula to identify between whole numbers and numbers with decimals

    Welcome to the Forum Jonor55!

    To tell if a number is a whole number:

    =IF(MOD(A1,1)=0,"Whole","Decimal")

    However, the example you gave doesn't make sense because all three examples are whole numbers, and they are all the same whole number:

    80 = 80.0 = 80.00

    In Excel, the only difference between those three numbers is how they are displayed. They are all stored as the same number.

    So it's completely unclear what you are trying to illustrate in your example. Also, one either adds or subtracts but not both at the same time. How do you decide which one you want to do? And how do you determine the value to add or subtract?

    It might help to explain the larger context--why do you need to do this?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    01-28-2019
    Location
    Scotland
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Formula to identify between whole numbers and numbers with decimals

    Forgot to put the the post below as reply to you.

  4. #4
    Registered User
    Join Date
    01-28-2019
    Location
    Scotland
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Formula to identify between whole numbers and numbers with decimals

    Sorry, I used 80 as an example, what i mean is X, X.X, X.XX, It is more to do with the number of decimal places in the rather than the numerical value. I was just going to use two different columns with the same script but change the minus to a plus.

    The larger context:

    I have a dimension X, then based on its value I will get a min / max tolerance, the tolerances vary depending whether it is X, X.X or X.XX

    Capture.JPG

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Formula to identify between whole numbers and numbers with decimals

    80 at A3:A5

    Please try at B3 drag to C3 and drag down

    =$A3+LOOKUP(IFERROR(LEN($A3)-FIND(".",$A3),0),{0,1,2},{2.5,0.8,0.38})*2*((COLUMNS($B3:B3))-1.5)

  6. #6
    Registered User
    Join Date
    01-28-2019
    Location
    Scotland
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Formula to identify between whole numbers and numbers with decimals

    I tried the formula you gave Bo and it works! Thanks so much!

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,872

    Re: Formula to identify between whole numbers and numbers with decimals

    FIND(".",$A3),0) will always give a #VALUE error when applied to a whole number, even if it is displayed with a decimal point and trailing zeroes as shown in the example. Similarly LEN will return 2 all the values shown in the first column.

    Jonor55, please attach an actual Excel file so we can test solutions without re-creating your file from scratch. The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

+ 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. [SOLVED] how to identify all numbers with 2-3 zero integers (round numbers)?
    By intreuefest in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-20-2018, 01:22 PM
  2. Formula for identify missing numbers from a given range.
    By Noorking in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-12-2015, 05:14 AM
  3. formula to convert cell numbers in inches and feet: 1'2" to decimals
    By ihill in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-16-2015, 09:45 AM
  4. [SOLVED] Is there a formula to delete whole numbers but leave decimals?
    By Miss Molko in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-22-2014, 08:46 AM
  5. [SOLVED] Convert all numbers stored as text or custom formatted to numbers &no decimals - 40 sheets
    By synses in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 01:46 AM
  6. [SOLVED] Creating Formula to identify repetitions of numbers
    By Rodh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-24-2012, 07:09 PM
  7. Identify Unused Numbers/Missing Numbers
    By gurp99 in forum Excel General
    Replies: 1
    Last Post: 05-31-2011, 07:11 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