+ Reply to Thread
Results 1 to 12 of 12

Subtracting with blank cells

  1. #1
    Registered User
    Join Date
    10-12-2015
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    95

    Subtracting with blank cells

    Hi everyone! I have encountered a problem; I need to find difference of 2 cell, but since one of these cells in my data is always blank, the formula returns a value error. How do I find a way around it?

    Thanks

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Subtracting with blank cells

    If it was truly blank, it would not return a value error. I'm guessing it contains "" as a result of a formula?
    If it's ALWAYS blank, then why are you subtracting it. If you know column B is always blank, then A-B = A. What am I missing?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    10-12-2015
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    95

    Re: Subtracting with blank cells

    Quote Originally Posted by ChemistB View Post
    If it was truly blank, it would not return a value error. I'm guessing it contains "" as a result of a formula?
    If it's ALWAYS blank, then why are you subtracting it. If you know column B is always blank, then A-B = A. What am I missing?
    yes, it contains "" as a result of formula although I have converted the formulas into values but it still is giving value error. Sometimes the column A is blank, other times column B is blank and there are almost 5000 such entries.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Subtracting with blank cells

    B1 should be blank itself, or returns "", " ", " " from calculation

    A1-B1 should be:

    =A1-IF(TRIM(B1)="",0,B1)
    Quang PT

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

    Re: Subtracting with blank cells

    @terry
    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Subtracting with blank cells

    Okay, so if your data starts in row 2 and we are subtracting A - B
    =IF(A2<>"", IF(B2<>"", A2-B2, A2), IF(B2<>"", -B2, 0)
    The above formula returns -B2 if A2 is blank (and B2 contains a value) and it returns 0 if both are blank

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Subtracting with blank cells

    Perhaps

    = N(A2)-N(B2)
    Does that work for your data?

  8. #8
    Registered User
    Join Date
    10-12-2015
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    95

    Re: Subtracting with blank cells

    @ Chemist, Yes, that does. Thanks a lot

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Subtracting with blank cells

    Quote Originally Posted by terry3218 View Post
    yes, it contains "" as a result of formula although I have converted the formulas into values but it still is giving value error.
    After converting formula blanks to values there is some kind of leftover "junk" in the cell even though you can't see it or calculate it.

    Consider this example.

    A1 formula: =IF(10>0,"","X")

    10 is > 0 so the formula returns blank "".

    Copy>Paste Special>Values

    The cell looks blank but it's not.

    =LEN(A1) = 0 (so you'd think the cell is empty but it's not)

    =A1="" = TRUE (so you'd think the cell is empty but it's not)

    =COUNTA(A1) = 1 WTH!

    The only way to get rid of the leftover "junk" is to clear or delete the cell contents.
    Last edited by Tony Valko; 12-02-2015 at 04:17 AM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Subtracting with blank cells

    If they are really "" and not " " or something like that I've found AutoFiltering for "Blanks", selecting those cells and hitting delete works.
    Dave

  11. #11
    Registered User
    Join Date
    02-22-2021
    Location
    Kansas City, MO
    MS-Off Ver
    MS Officer 2016
    Posts
    1

    Re: Subtracting with blank cells

    Hi there,
    I am new to the forum and have an excel formula question that I haven't been able to crack.
    I am trying to calculate the difference between two cells and some of the cells are blank and it's not returning the info I am seeking.
    I'm currently using =A2-B2 and getting the correct difference. However, when I have a blank cell in the "B" column I'm getting the value in the "A" column as the answer. I need a formula that will give an answer with a blank column as false or something that won't equal column "A". This is so I can get an accurate amount of my over/under for my budget. Thank you for any advise and help on this. Please see the example attached.
    Attached Files Attached Files

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Subtracting with blank cells

    Hello BigJ7013. Welcome to the forum.

    Administrative Note:

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

+ 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. Count blank cells in a range and contiguous blank cells also as single cells! Tricky One!
    By SebastianColombia in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-31-2015, 02:32 PM
  2. subtracting cells from next value
    By The Fly in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-06-2015, 11:40 PM
  3. Subtracting from different cells
    By nkitchen31 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-22-2014, 05:14 PM
  4. Replies: 0
    Last Post: 05-08-2012, 12:42 PM
  5. subtracting dates results in a big number when a date field is blank
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-23-2009, 11:26 AM
  6. Subtracting to a blank cell
    By jephrey_dal in forum Excel General
    Replies: 4
    Last Post: 05-27-2007, 10:40 PM
  7. Subtracting From 2 Cells
    By scw1217 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-04-2006, 08:56 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