+ Reply to Thread
Results 1 to 7 of 7

Volatility Calculation stopped working

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2012
    Location
    Stamford, CT
    MS-Off Ver
    Excel 2003
    Posts
    24

    Volatility Calculation stopped working

    Below is the code
    rngvol is the number of volatility days(much like a 30 day moving average is over the previous 30 days)
    volcalc is the number of rows of data in the given column

    'Statistical Volatility Calculation 1



    rngvol = Worksheets("config").Cells(32, 2)
    volcalc = WorksheetFunction.CountA(Sheets("INFO").Range("A:A"))

    Do Until Worksheets("info").Cells(rngvol + i + 1, 1).Value = ""
    For i = 1 To volcalc - rngvol + 1
    cor1 = WorksheetFunction.StDev(INFO.Range(INFO.Cells(2 + i, 4), INFO.Cells(rngvol + i + 1, 4)).Value)
    volatility1 = cor1 * Worksheets("config").Cells(38, 2).Value
    Worksheets("info").Cells(rngvol + i + 1, 8).Value = volatility1

    Next i
    Exit Do

    Loop

  2. #2
    Forum Contributor
    Join Date
    03-15-2007
    Location
    AL, USA
    MS-Off Ver
    2007
    Posts
    174

    Re: Volatility Calculation stopped working

    Quote Originally Posted by ajc5382 View Post
    Below is the code
    rngvol is the number of volatility days(much like a 30 day moving average is over the previous 30 days)
    volcalc is the number of rows of data in the given column

    'Statistical Volatility Calculation 1



    rngvol = Worksheets("config").Cells(32, 2)
    volcalc = WorksheetFunction.CountA(Sheets("INFO").Range("A:A"))
    
    Do Until Worksheets("info").Cells(rngvol + i + 1, 1).Value = ""
        For i = 1 To volcalc - rngvol + 1
            cor1 = WorksheetFunction.StDev(INFO.Range(INFO.Cells(2 + i, 4), INFO.Cells(rngvol + i + 1, 4)).Value)
            volatility1 = cor1 * Worksheets("config").Cells(38, 2).Value
            Worksheets("info").Cells(rngvol + i + 1, 8).Value = volatility1
            
        Next i
    Exit Do
    
    Loop
    You may get a better response if you moved your post, or asked a mod to do so, to the programming sub-forum, and don't forget to wrap your code using the code tags

    What indication do you have that it stopped working? Any errors or messages?
    Last edited by mshale; 06-29-2012 at 05:44 PM.

  3. #3
    Registered User
    Join Date
    06-25-2012
    Location
    Stamford, CT
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Volatility Calculation stopped working

    Quote Originally Posted by mshale View Post
    You may get a better response if you moved your post, or asked a mod to do so, to the programming sub-forum, and don't forget to wrap your code using the code tags

    Thanks for the response. What indication do you have that it stopped working? Any errors or messages?
    I'm new on here so I'm not sure what/where code tags are. The code actually runs fine, but it won't populate the appropriate columns and I'm not sure why.


    Where did you say I should post this. I'm somewhat desperate for an answer, a large project I'm working on is being held up because of this.

  4. #4
    Forum Contributor
    Join Date
    03-15-2007
    Location
    AL, USA
    MS-Off Ver
    2007
    Posts
    174

    Re: Volatility Calculation stopped working

    I'm assuming that you have already opened your VB editor and stepped through the code using F8 and watched it take place in your sheet? If it used to work, and you're certain that your code has not been modified, then something in the sheet itself has been modified. If a cell moved, or a reference changed, then that could be what is cosign the problem. Your code/syntax looks to be in order.

    Cross posting is generally frowned upon, so you shouldn't go to the Programming section and post, you should see about getting it moved there. Here is a link:
    http://www.excelforum.com/excel-programming/

    The code tags are in the formatting bar right above where you type your post. It's the button that looks like "#"
    Last edited by mshale; 06-30-2012 at 10:36 AM.

  5. #5
    Registered User
    Join Date
    06-25-2012
    Location
    Stamford, CT
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Volatility Calculation stopped working

    Quote Originally Posted by mshale View Post
    I'm assuming that you have already opened your VB editor and stepped through the code using F8 and watched it take place in your sheet? If it used to work, and you're certain that your code has not been modified, then something in the sheet itself has been modified. If a cell moved, or a reference changed, then that could be what is cosign the problem. Your code/syntax looks to be in order.

    Cross posting is generally frowned upon, so you shouldn't go to the Programming section and post, you should see about getting it moved there. Here is a link:
    http://www.excelforum.com/excel-programming/

    The code tags are in the formatting bar right above where you type your post. It's the button that looks like "#"
    Thanks for the pointers, noted. With regards to the code, there is one thing I changed slightly. I multiplied the result of the StDev function by a cell in my worksheet. But that is all.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,987

    Re: Volatility Calculation stopped working

    Are you not getting any results in the cells?
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Forum Contributor
    Join Date
    03-15-2007
    Location
    AL, USA
    MS-Off Ver
    2007
    Posts
    174

    Re: Volatility Calculation stopped working

    You could take out the part where you multiplied the stddev by the value in B38, and see what stepping thorough the code does for you. Perhaps the code is attempting to multiply a number by a string...

    Without a sample sheet, that's about all we can do

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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