+ Reply to Thread
Results 1 to 3 of 3

Thread: Syntax Error calling StDev Function

  1. #1
    Registered User
    Join Date
    10-28-2009
    Location
    Wilmington,DE
    MS-Off Ver
    Excel 2007
    Posts
    38

    Syntax Error calling StDev Function

    Dear Forum Members,

    I am having trouble getting this code to run. Apparently, the StDev function cannot be called. Any help on the syntax will be greatly appreciated.


    Sub DoCalcualtions(ByRef rForm As Long, ByRef lngBeginRange As Long, ByRef lngEndRange As Long, ByVal intLastCol As Integer)
    Dim c As Integer
    '
    FormHeader rForm, intLastCol
    '
    For c = 3 To intLastCol
        Worksheets("Form").Cells(rForm + 1, c) = Worksheets("Data").Application.WorksheetFunction.StDev(Range(Cells(lngBeginRange, c), Cells(lngEndRange, c)))    
        
        
    Next c
    '
    rForm = rForm + 7
    End Sub
    Chris

  2. #2
    Forum Guru mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    3,004

    Re: Syntax Error calling StDev Function

    Try the simpler...

    Worksheets("Form").Cells(rForm + 1, c) = WorksheetFunction.StDev(Range(Cells(lngBeginRange, c), Cells(lngEndRange, c)))
    or

    Worksheets("Form").Cells(rForm + 1, c) = WorksheetFunction.StDev(Range(Cells(lngBeginRange, c).Value , Cells(lngEndRange, c).Value))
    Martin

    Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.

    If my solution has saved you time and/or money, please consider donating to Cancer Research UK.

  3. #3
    Registered User
    Join Date
    10-28-2009
    Location
    Wilmington,DE
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Syntax Error calling StDev Function

    Dear Martin,

    I have been staring at this screen for hours, making minor adjustments but could not get it right! I copied your code (the first one) into the macro and it ran perfectly! Thank you so much - this is a big break for me.

    Chris

    [SOLVED]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0