+ Reply to Thread
Results 1 to 4 of 4

How to adapt this macro to allow for missing values?

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    How to adapt this macro to allow for missing values?

    Dear all,

    The macro below works well. But if any cell contains #NA or missing values, it will fail to work. My question is: how to make this macro work to ignore all non-numeric values?

    Function MaxDrawDown(returns As Variant) As Variant
    Dim TS As Variant
    Dim n As Integer
    Dim Min As Double
    TS = returns
    n = UBound(TS)
    Min = 0
    For i = 1 To n
    For j = i To n
    temp = TS(j, 1) / TS(i, 1) - 1
    If temp < Min Then
    Min = temp
    End If
    Next
    Next
    MaxDrawDown = Min
    End Function

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to adapt this macro to allow for missing values?

    Try this:-
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    Re: How to adapt this macro to allow for missing values?

    Thanks, Mick. It worked well

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to adapt this macro to allow for missing values?

    Thanks for the feedback
    Rgrds Mick

+ 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