+ Reply to Thread
Results 1 to 9 of 9

STDEV: Different results. Bug-like in Excel 2010

  1. #1
    Registered User
    Join Date
    04-01-2015
    Location
    Nigeria
    MS-Off Ver
    2010
    Posts
    5

    Question STDEV: Different results. Bug-like in Excel 2010

    Hello,

    I am using VBA for a model which requires calculation of Standard Deviation.
    The model already exists in Excel, using STDEV application function, so the VBA model is expected to give the same result.

    However, using VBA's Worksheet.applicationfunction.STDEV gives a different result from the STDEV result computed in the cells. Both computations were done on the same data.

    I have used the 6 different functions available in Excel, the results are as follows:
    STDEV = 0.0052071061943
    STDEVA = 0.0052071061943
    STDEVS = 0.0052071061943
    STDEVPA = 0.0052037969431
    STDEVP = 0.0052037969431
    STDEVP = 0.0052037969431

    The 3 functions available in VBA also give different results, none of which agree with any of the ones computed in Excel. VBA Results:
    STDEV = 0.0052038062902
    STDEVS = 0.0052038062902
    STDEVP = 0.0052005033345


    The temporary solution I have adopted is to have a formula in a designated cell, compute STDEV using the Excel function, and then have VBA pick the result from that cell.

    Has anyone else noticed this problem?
    Is there an explanation for this?
    Is there a better workaround?

    Thank you

    Yemi

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: STDEV: Different results. Bug-like in Excel 2010

    STDEV, STDEV.A and STDEV.S all calculate std deviation based on the formula for the sample standard deviation (using n-1 in the divisor). The others calculate the population standard deviation (using n in the divisor).

    I can't answer for VBA.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    04-01-2015
    Location
    Nigeria
    MS-Off Ver
    2010
    Posts
    5

    Re: STDEV: Different results. Bug-like in Excel 2010

    Thank you Glenn for your response,
    Yes, I noticed the difference between Stdev-sample and Stdev-population.
    The problem is that using these same functions with Application.Worksheetfunction.StdevA,P or S in VBA produces different results.

    I'd like to know how others handle this.

    Thank you

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: STDEV: Different results. Bug-like in Excel 2010

    not seeing different results in xl2010.

    Also the help in worksheetfunction.stdev* is quite useful.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    04-01-2015
    Location
    Nigeria
    MS-Off Ver
    2010
    Posts
    5

    Re: STDEV: Different results. Bug-like in Excel 2010

    Thanks Andy, You are right! It seems something else is responsible for the differences.
    I am looking but have not yet found the cause.
    I am computing the STDEV on an array in VBA. I see no reason why it should be different from what is returned when i write the array values to worksheet cells and compute STDEV to check.

    I will let you know if i find the source of the diff.
    Thank you

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: STDEV: Different results. Bug-like in Excel 2010

    You could post your code and/or a workbook.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    04-01-2015
    Location
    Nigeria
    MS-Off Ver
    2010
    Posts
    5

    Re: STDEV: Different results. Bug-like in Excel 2010

    I have found the source of the problem!

    myArray is dimmed to hold more data than the sample I need to compute STDEV, some lines in my procedure store only 500 of the data to myArray and then compute STDEV(myArray)...despite the empty array elements.

    I expected the result to be same as what happens in Excel, where STDEV function does nothing differently when you include empty cells.

    I have now dimed my array 1 to 500, and the result is exactly the same as what Excel returns in the Worksheet.

    Thank you all for your helpful responses.STDEV 1075414.xlsm

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: STDEV: Different results. Bug-like in Excel 2010

    where STDEV function does nothing differently when you include empty cells
    Your array is of type Double; elements can never be Empty -- uninitialized values contain 0.

    If the array were of type Variant, uninitialized values would be Empty, and ignored by StDev. That's not to suggest you do that.

  9. #9
    Registered User
    Join Date
    04-01-2015
    Location
    Nigeria
    MS-Off Ver
    2010
    Posts
    5

    Re: STDEV: Different results. Bug-like in Excel 2010

    Thanks shg, I have tried with variant data type, and it works!STDEV Neww 1075414.xlsm
    Last edited by Yemitubosun; 04-02-2015 at 06:05 AM.

+ 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. Excel 2010 Filter a value then displaying results
    By Lensmeister in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-29-2015, 06:48 AM
  2. [SOLVED] Excel 2010 Formula Help - Trying to return various results
    By WestLondonGuy78 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-06-2012, 09:07 AM
  3. Linking results from one sheet to another excel 2010
    By FDG in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2012, 03:25 PM
  4. Showing Formula Results Excel 2010
    By Longmont123 in forum Excel General
    Replies: 1
    Last Post: 11-30-2010, 06:18 AM
  5. [SOLVED] StDev Results
    By Michael in forum Excel General
    Replies: 1
    Last Post: 08-22-2005, 05:05 PM

Tags for this Thread

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