+ Reply to Thread
Results 1 to 9 of 9

Referencing the cell's answer in another formula

  1. #1
    Registered User
    Join Date
    06-27-2016
    Location
    Winnipeg
    MS-Off Ver
    2007
    Posts
    3

    Referencing the cell's answer in another formula

    Hi there,
    I'm new to this forum and am learning excel. I have a lot of programming experience, and this problem seems trivial, but I can't figure it out.

    All cells in the following example use currency formatting. The quotes are there just for display, they are not entered in the real input box.

    I have a cell, let's say A1. I've inputted a value of 200.
    B1 has this inputted: '=A1*0.05'
    C1 has '=A1+B1'

    So far so good, C1 shows the correct calculation.

    I have another cell D1 which I use to input an amount.

    In E1, I have this: '=IF(C1=D1, D1*0.8, 0)'

    After inputting the same value into D1 as seen in C1, this is where the problem lies. Even though both C1 and D1 cells show the same value, E1 returns 0. It seems it's comparing the formula of C1 as text, not the value the formula returned.

    I've tried this:
    '=IF(value(C1)=value(D1), D1*0.8, 0)'

    and using the Cell function, but nothing works.

    I would think that when you refer to a cell name, it returns the value calculated by the formula inside it, not the formula itself. That's how any programming language works. When you refer to a variable or function, it returns the value found in that variable or the value returned by the function.

    Any help would be great. Thanks

  2. #2
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Quebec, Canada
    MS-Off Ver
    2013
    Posts
    232

    Re: Referencing the cell's answer in another formula

    Could you possibly post the workbook? I don't have that issue if I do the same steps as you did

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Referencing the cell's answer in another formula

    What you are expecting is how Excel should work.

    If you copy C1 and Right-Click and Paste Values into D1 (the little 123 icon) does the formula work correctly? If so, then the value of C1 and D1 may not be exactly the same due to floating point precision and rounding rules when dealing with values around 15 digits long.


    For example, 1.9999999999999999*.05 approx 2.1 according to Excel. If I put 2.1 in D1, the formula does not work.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  4. #4
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Quebec, Canada
    MS-Off Ver
    2013
    Posts
    232

    Re: Referencing the cell's answer in another formula

    Yeah you are right daffodil about that, but I doubt that would be the issue if he did input a value of 200, since is only generates integers in that case

  5. #5
    Registered User
    Join Date
    06-27-2016
    Location
    Winnipeg
    MS-Off Ver
    2007
    Posts
    3

    Re: Referencing the cell's answer in another formula

    Quote Originally Posted by daffodil11 View Post
    What you are expecting is how Excel should work.

    If you copy C1 and Right-Click and Paste Values into D1 (the little 123 icon) does the formula work correctly? If so, then the value of C1 and D1 may not be exactly the same due to floating point precision and rounding rules when dealing with values around 15 digits long.


    For example, 1.9999999999999999*.05 approx 2.1 according to Excel. If I put 2.1 in D1, the formula does not work.
    Ahhh, thank you, it's a precision problem. It works if I copy the value like you said. But how do I make sure everything gets rounded correctly? Because everything I enter has only 2 decimals, and everything that is displayed has only 2 decimals. And all boxes use currency formatting.

  6. #6
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Quebec, Canada
    MS-Off Ver
    2013
    Posts
    232

    Re: Referencing the cell's answer in another formula

    You could use the Round function

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Referencing the cell's answer in another formula

    You could coerce the rounding with =ROUND(A1+B1,2) or even drop the fractions of a penny altogether with =VALUE(TEXT(A1+B1,"#.00")).

    Sounds like the plot to Superman III.

  8. #8
    Registered User
    Join Date
    06-27-2016
    Location
    Winnipeg
    MS-Off Ver
    2007
    Posts
    3

    Re: Referencing the cell's answer in another formula

    Quote Originally Posted by Jdevil View Post
    You could use the Round function
    Great, using Round to 2 decimals worked like a charm. I keep forgetting about floating point problems like this. Thanks everyone

  9. #9
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Referencing the cell's answer in another formula

    No problem, glad we could help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. 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. [SOLVED] Formula that changes answer cell based on numeric value in reference cell
    By dtinman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-28-2014, 12:41 PM
  2. Replies: 6
    Last Post: 07-14-2014, 03:45 PM
  3. Cross Referencing - VLookup Not The Answer?
    By Benspot in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 07-11-2014, 03:12 PM
  4. [SOLVED] is there a way to get the cell address of the answer of a formula
    By cher062 in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 01-07-2014, 11:21 AM
  5. Replies: 1
    Last Post: 11-21-2012, 02:03 AM
  6. [SOLVED] Cross-referencing two columns to get one answer
    By LordVankar in forum Excel General
    Replies: 10
    Last Post: 03-29-2012, 04:29 PM
  7. Formula answer does not appear in cell.
    By rushdenx1 in forum Excel General
    Replies: 2
    Last Post: 06-13-2010, 05:05 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