+ Reply to Thread
Results 1 to 8 of 8

wrong calculation value

  1. #1
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    wrong calculation value

    Please Login or Register  to view this content.
    A small part of a VBA that calculates the wrong value and I am not sure why. Any ideas? Thank you very much.

    D2 = 7
    E2 = 4
    F2 = 31 (should be 28)

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: wrong calculation value

    Hi,

    As stated I get F2 to be 24.

    Can you explain in a note what you are trying to do. At the moment all that macro is doing is putting the number 4 in E2:E9 and the formula in F2:F9. But first of all the formula is not an absolute reference formula, and I suspect that's really what you want, and when you have something like
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    the first bit where you seem to be trying to multiply by 4 is only multiplying D2 by 4, and the last bit where you seem to deduct the sum of e2:e9 is in fact only deducting the e2 value.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,638

    Re: wrong calculation value

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: wrong calculation value

    If the value in E2 is 4 then the value in F2 should be 28. The value in D2 is the select statement that applies the same formula as long as the value is less than 15. I think I need an absolute reference formula as you suggested, but am not familiar with how this is done.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: wrong calculation value

    Hi

    With a formula like =D2*4-E2 with D2=7, E2=4, then the answer is bound to be 24. Are you sure you do want to deduct E2? Leaving the E2 deduction out is the only way I can see how you would get 28.

  6. #6
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: wrong calculation value

    Hi,

    The value of 24 is what I am trying to get (D2*4-E2), but as of now when I run the code I get a value of 31. Below is the entire code and below that are examples of the output as of now. Thanks.

    Please Login or Register  to view this content.
    mean dilution factor μL gDNA μL H2O
    1.35 7 4 31 (should be 24)
    1.60 8 4 38 (should be 28)

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: wrong calculation value

    Quote Originally Posted by cmccabe View Post
    Hi,

    The value of 24 is what I am trying to get (D2*4-E2), but as of now when I run the code I get a value of 31. Below is the entire code and below that are examples of the output as of now. Thanks.
    ...but that isn't what you said in post #4. You said you wanted 28.
    This is getting confusing. I suggest rather than just post your code you upload the whole workbook so that we can see things in action.
    Tell us in a narrative form how you use the workbook, i.e. what cells you change, what you expect to happen and when you want to run the macro.

    To the right of your results cells in a spare area, manually add the results you expect to see after the macro has run so that we can see the end goal. Tell us which are the manually entered desired results.

  8. #8
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: wrong calculation value

    I attached the spreadsheet (NGS_Calculator)

    the two cells in red and the two rows labelled empty do not work either, but that is a separate issue. The cells in red are supposed to calculate, but if the value in the dilution factor (column D) is less than 5 they also hightlight red. If the sample name is empty then "-" is supposed to be the cell value for column D,E, and F. Thanks.
    Last edited by cmccabe; 04-05-2014 at 01:55 PM.

+ 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 remove decimal point because wrong calculation
    By redza in forum Excel General
    Replies: 6
    Last Post: 09-26-2013, 02:08 AM
  2. [SOLVED] Help with SUMIF using multiple rows - wrong calculation
    By lulugonlolo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-09-2012, 01:15 AM
  3. right calculation wrong answer
    By allinfernandez in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-06-2012, 10:07 AM
  4. wrong calculation when extending variable ranges
    By fxhst329 in forum Excel General
    Replies: 7
    Last Post: 01-30-2011, 05:37 PM
  5. Time Calculation-What am I doing wrong?
    By Latlong in forum Excel General
    Replies: 4
    Last Post: 10-14-2009, 01:51 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