+ Reply to Thread
Results 1 to 17 of 17

formatting negative numbers

  1. #1
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    formatting negative numbers

    hi, can anyone help with the following problem,

    i have the following formula set up in cell K5:- =IF(C5="Y",G5,G5-D5)

    the formula works as it should however if G5 is less than D5 it returns ########### (negative number) in cell K5

    i tried to combat this by using conditional formatting and returning a zero instead. this worked however if the number is positive it still returns zero in the cell. (confusing though as although it returns zero when positive it still identifies the number as it still performs for another formula?) The number in K5 is then x by the amount in K6,

    so lets say G5=5, D5=10 then G5-D5=-5 so returns ############
    but if G5=10. D5=5 then G5-D5=5 but returns 0.(IN k5)
    but then K5=0 K6=£13 - the answer still returns £65 which is correct? (even though K5 is showing as 0 and not the 5 i want it to)




    thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    Maybe try this?

    =IF(C5="Y",G5,MAX(0,G5-D5))

    Attach the workbook if you want any further help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    Re: formatting negative numbers

    Thank you Ali , that works perfectly.

    Phil

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks for the rep comment.

  5. #5
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    Re: formatting negative numbers

    would it be possible to extend on that formula so that instead of showing the result in time format it will return as number format instead.
    so for example at present it would return 09:00 but i would like it to return 9

    phil

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    Again, without the workbook, not easy to say. Is that 9 hours or 9 minutes?

    Try this:

    =IF(C5="Y",text(G5,"h"),MAX(0,text(G5-D5),"h"))

    or:

    =IF(C5="Y",text(G5,"m"),MAX(0,text(G5-D5),"m"))

    Obviously untested ...

  7. #7
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    Re: formatting negative numbers

    unfortunately that one does not work, just uploaded uploaded work book but i cant get it onto post?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    Follow the instructions in the yellow banner at the top of the page.

  9. #9
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    Re: formatting negative numbers

    i have tried that. it allows me to upload it but then cant attach to message
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    Re: formatting negative numbers

    looks like i have mange to upload it

    phil

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    OK - where am I looking? Where (which cell) will I find the formula?

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    I changed the formatting of K5, K8, etc. to simply h.
    Attached Files Attached Files

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  14. #14
    Registered User
    Join Date
    02-24-2022
    Location
    wigan england
    MS-Off Ver
    office 365
    Posts
    13

    Re: formatting negative numbers

    hi i tried that previously however when performing its next function it is incorrect. for example if it returns 9 as apposed to 09:00 because its formatted as h. (if i then did k5 x 3 it wouldnt return 27 it would return 3

    apologies for being a pain

    Phil

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: formatting negative numbers

    Please provide a sample workbook that SHOWS the PROBLEM and tell us anything else you have already tried to save time all around.

  16. #16
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: formatting negative numbers

    hi i tried that previously however when performing its next function it is incorrect. for example if it returns 9 as apposed to 09:00 because its formatted as h. (if i then did k5 x 3 it wouldnt return 27 it would return 3
    I think you are falling prey to one of the challenges of working in a spreadsheet -- understanding the difference between "what you see in the cell (the display)" and "the actual cell's value (what Excel sees in the cell)". Number formatting is a powerful and useful thing in spreadsheets, but it leads to cases (and date/time values are probably the most common expression of this) where what you see in the cell is very different from what Excel sees in the cell.

    The key thing as a programmer that you need to become comfortable with when working date/time serial numbers is that Excel stores time as a fraction of a day. The value "6 hours" (however you choose to format that value) is stored in Excel as 0.25 (6/24 or 1/4 of a day). This means that, whenever you need to use the time value (remember that the value Excel sees is in units of "days") with a rate (something/unit time), the key to getting the calculation to work is a simple unit conversion -- either make sure that your rate is in units of "something/day" [=rate/CONVERT(1,"unit time","days")] or convert the time value that Excel sees from "days" to whatever time unit your rate uses (if its and hourly rate, then convert Excel's time value from days to hours) [=CONVERT(time value,"days","hrs")].

    There are, of course, lots of different ways to perform the unit conversion. I like to use the CONVERT() function mostly because it helps me remember the purpose of the calculation -- namely that I am performing a unit conversion. In the end, you as the programmer can decide exactly how you like to perform the unit conversion.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  17. #17
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: formatting negative numbers

    In your sheet, for example, I might replace the "pounds per hour" rates in column T (at least, I'm assuming they are "pounds per hour") with "pounds per day" rates of 24 (in place of the 1 pound/hr values) and 120 (in place of the 5 pounds/hr). Then I can use the times (in days) as Excel sees them. Again, you as the programmer can decide exactly how you want to do this, but the key step is how do you want to reconcile values that involve times in hours and values that involve times in days so that those values are using consistent time units.

+ 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] Conditional Formatting numbers as negative but will not add properly
    By dezspert22 in forum Excel General
    Replies: 4
    Last Post: 01-26-2017, 06:38 PM
  2. [SOLVED] Formatting negative numbers using brackets
    By malcmail in forum Excel General
    Replies: 4
    Last Post: 03-06-2015, 08:01 PM
  3. Axis Formatting Negative Numbers
    By laguna92651 in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 05-01-2014, 01:23 PM
  4. [SOLVED] Formatting numbers to have negative in brackets
    By onroute in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-03-2014, 04:54 PM
  5. Excel 2007 : Formatting negative numbers
    By littlemy111 in forum Excel General
    Replies: 5
    Last Post: 11-11-2011, 04:48 AM
  6. Contional formatting negative numbers and percentages
    By capnhud in forum Excel General
    Replies: 4
    Last Post: 10-18-2011, 09:08 AM
  7. Quick formatting for negative numbers
    By Mulepadre in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-24-2006, 11: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