Consulting

Results 1 to 6 of 6

Thread: Create simplified function

  1. #1
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location

    Create simplified function

    Hi, is there a way of creating a function that can that summarise this array formula?

    Function SUMELIG(ByVal rngElig As Range, rngPercentage As Range)
    SUMELIG.FormulaArray = "=SUM(IF(ISERROR(rngElig * rngPercentage),0, rngElig))"
    End Function
    Thanks R

  2. #2
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    The code quoted above doesn't work, any ideas? If there is a better non-vba way to deal with this then that's great.

    Thanks

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this what you want

    Function SUMELIG(ByVal rngElig As Range, rngPercentage As Range) 
    SUMELIG = Application.Evaluate(SUM(IF(ISERROR(" & rngElig.Address & " * " & rngPercentage.Address & "),0, " & rngElig.Address & "))" 
    End Function
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    Thanks, it seems to be but the second line comes up in red, can you help?

  5. #5
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    Here is the solution that seems to work, thanks XLD

    Function SUMELIG(ByVal rngElig As Range, rngPercentage As Range)
    SUMELIG = Application.Evaluate("SUM(If(ISERROR(" & rngElig.Address & " * " & rngPercentage.Address & "),0, " & rngElig.Address & "))")
    End Function

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Oops, what a plonker (me!)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •