+ Reply to Thread
Results 1 to 5 of 5

Moving Standard deviation

  1. #1
    Registered User
    Join Date
    12-04-2008
    Location
    chicago
    Posts
    11

    Smile Moving Standard deviation

    I am trying to learn VBA and started reading Wallenbach's book and I thought the best way to get up to speed fast was to work on some real problems.

    So this is what I am trying to do.

    I have a list of about 1000 stock price returns in the following format

    jan 1 2008 .033
    jan 2 2008 .01
    jan 3 2008 -.002
    jan 4 2008 -.0033
    jan 5 2008 .04

    What I want to do is calculate in VBA a moving 3 day standard deviation of returns. So I want the first calculation to include jan 1 - jan 3 and place the answer in the cell to the right of jan 3 return. Then move down 1 row and calculate the standard deviation using jan 2 - jan4 and place the answer in the cell to the right of jan 4 return...and so on until the last cell.

    Thanks
    Last edited by asavage; 12-05-2008 at 09:35 PM. Reason: add solved to thread

  2. #2
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764
    Hi
    try these codes
    Please Login or Register  to view this content.
    Ravi

  3. #3
    Registered User
    Join Date
    12-04-2008
    Location
    chicago
    Posts
    11
    That Worked! I had to make one small change, I had to have the STDev function use col "B" not "A". But You hit it perfectly!

    I have another question for you. I was trying to use

    WorksheetFunction.Stdev(rangebegin range end) but I didn't know how to pass range values into the function and get the range values move all the way down the worksheet.

  4. #4
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764
    HI
    try this
    Please Login or Register  to view this content.
    Ravi

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try this

    Please Login or Register  to view this content.
    rylo

+ 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.6.0 RC 1