+ Reply to Thread
Results 1 to 2 of 2

Using FormulaArray in VBA

  1. #1
    Registered User
    Join Date
    03-03-2006
    Posts
    1

    Using FormulaArray in VBA

    I need to write a function the sums two arrays and return an array as a result. This has to be made using FormulaArray. I've tried some thing as showed below, but doesn't work.

    Function FFF(MinhaSelecao1 As Range, MinhaSelecao2 As Range) As Range

    FFF.ArrayFormula = "=" & MinhaSelecao1 & "+" & MinhaSelecao2

    End Function


    Does anyone can help me?

  2. #2
    Tom Ogilvy
    Guest

    Re: Using FormulaArray in VBA

    FormulaArray is for entering an Arrayformula in a Worksheet.

    Closest you could get would be

    Function FFF(MinhaSelecao1 As Range, MinhaSelecao2 As Range) As Variant
    FFF = Evaluate( MinhaSelecao1.Address & "+" & MinhaSelecao2.Address)
    End Function


    otherwise

    Function FFF(MinhaSelecao1 As Range, MinhaSelecao2 As Range) As Variant
    Dim v as Variant
    v1 = MinhaSelecao1.Value
    v2 = MinhaSelecao2.Value

    for i = to 1 to ubound(v1,1)
    v1(i,1) = v1(i,1) + v2(i,1)
    Next
    FFF = v1
    End Function

    This would give you a return array of the same size as the ranges passed in.

    --
    Regards,
    Tom Ogilvy


    "marcelobf" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I need to write a function the sums two arrays and return an array as a
    > result. This has to be made using FormulaArray. I've tried some thing
    > as showed below, but doesn't work.
    >
    > -Function FFF(MinhaSelecao1 As Range, MinhaSelecao2 As Range) As Range
    >
    > FFF.ArrayFormula = "=" & MinhaSelecao1 & "+" & MinhaSelecao2
    >
    > End Function-
    >
    > Does anyone can help me?
    >
    >
    > --
    > marcelobf
    > ------------------------------------------------------------------------
    > marcelobf's Profile:

    http://www.excelforum.com/member.php...o&userid=32129
    > View this thread: http://www.excelforum.com/showthread...hreadid=518850
    >




+ 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