+ Reply to Thread
Results 1 to 3 of 3

Function that return a a vector or a table

  1. #1
    Jean-Pierre Bidon
    Guest

    Function that return a a vector or a table

    Hi,
    Is it possible for a function to return an array...and how?
    Any help would be appreciated.
    Thank you
    Jean-Pierre Bidon



  2. #2
    Dave Peterson
    Guest

    Re: Function that return a a vector or a table

    Yep. You can have the array returned to that single cell or to a range of
    cells.

    Option Explicit
    Function testme() As Variant

    Dim iCtr As Long
    Dim myArr(1 To 10) As String

    For iCtr = 1 To 10
    myArr(iCtr) = "test" & iCtr
    Next iCtr

    testme = Application.Transpose(myArr)

    End Function

    Select A1:A10, type =testme() and hit ctrl-shift-enter.

    Jean-Pierre Bidon wrote:
    >
    > Hi,
    > Is it possible for a function to return an array...and how?
    > Any help would be appreciated.
    > Thank you
    > Jean-Pierre Bidon


    --

    Dave Peterson

  3. #3
    Jean-Pierre Bidon
    Guest

    Re: Function that return a a vector or a table

    I tried your solution and it works.
    Thank you Dave.
    Jean-Pierre

    "Dave Peterson" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > Yep. You can have the array returned to that single cell or to a range of
    > cells.
    >
    > Option Explicit
    > Function testme() As Variant
    >
    > Dim iCtr As Long
    > Dim myArr(1 To 10) As String
    >
    > For iCtr = 1 To 10
    > myArr(iCtr) = "test" & iCtr
    > Next iCtr
    >
    > testme = Application.Transpose(myArr)
    >
    > End Function
    >
    > Select A1:A10, type =testme() and hit ctrl-shift-enter.
    >
    > Jean-Pierre Bidon wrote:
    >>
    >> Hi,
    >> Is it possible for a function to return an array...and how?
    >> Any help would be appreciated.
    >> Thank you
    >> Jean-Pierre Bidon

    >
    > --
    >
    > Dave Peterson




+ 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